-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Extension type expression evaluation error when from closure parameter #56911
Comments
Summary: The issue is that extension type expression evaluation fails when the extension type is used as a parameter in a closure. The evaluation throws a |
Also, if you place a breakpoint on line 21 ( evaluateInFrame: (113) Expression compilation error
org-dartlang-debug:synthetic_debug_expression:1:1: Error: The getter 'i' isn't defined for the class '_Uint8List'.
- '_Uint8List' is from 'dart:typed_data'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'i'.
i.value
^ If you add to extension type A._(Uint8List i) implements Uint8List { When you evaluate on |
cc @bkonyi |
One more thing that I'm not sure it is related but it seems that this has lots of related problems: Change extension type B._(A i) implements A {
factory B(int i) {
foo();
return B._(A(i));
}
static void foo() {}
bool get value2 => i.value == 0;
} When you evaluate evaluateInFrame: (113) Expression compilation error
org-dartlang-debug:synthetic_debug_expression:1:1: Error: Method not found: 'foo'.
foo()
^^^ If |
One last thing (I think 🙃) I noticed this when trying to hover a getter I had defined (like |
Thanks for the detailed report @FMorschel! Having a reproduction case is extremely helpful! FYI @johnniwinther @jensjoha, I think this might be a CFE issue? |
Given that it happens when attempting to display a hover, I'm fairly sure it's an analyzer issue (either only or also). |
@bwilkerson, I'm not sure I was clear enough (or I'm not aware of how it works). This is the hover output when not debugging: This is the hover output when debugging of This is the hover output when debugging of I was expecting to see EditThat's why I'm not sure I was clear. I don't see how the analysis could get me the current value for the running program on the hover. |
When not debugging, the analysis server provides the hover. When you are debugging, VS Code extracts the expression under the mouse and sends it to the debugger for evaluation. Based on the screenshot above, I suspect that when that fails, VS Code falls back to using the language-server hover. So I think the issue here is in the debugger, not correctly evaluating |
@bkonyi while there is some inconsistency on the CFE side (the line 21 thing in #56911 (comment) --- this is caused by being paused on the getter, not inside it, making the CFE side not find the It seems to me the CFE compiles the right thing correctly and sends it to the VM. The VM then somehow passes an I can even crash the VM by asking to compile something else:
and in the terminal I now have this:
|
member. See #56911 (comment) for context. Bug: #56911 Change-Id: If990f41c58268b592d575e1280831b1ed120d54d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392341 Reviewed-by: Johnni Winther <[email protected]> Commit-Queue: Jens Johansen <[email protected]>
I added these logging statements: #if !defined(PRODUCT)
for (intptr_t i = 0; i < eval_function.NumParameters(); ++i) {
OS::PrintErr(
"parameter_names[%ld]: %s\n", i,
String::Handle(eval_function.ParameterNameAt(i)).ToCString());
OS::PrintErr(
"parameter_types[%ld]: %s\n", i,
AbstractType::Handle(eval_function.ParameterTypeAt(i)).NameCString());
}
for (intptr_t i = 0; i < arguments.Length(); ++i) {
OS::PrintErr("arguments[%ld]: address: %p, type: %s\n", i,
arguments.At(i).untag(),
Object::Handle(arguments.At(i)).JSONType());
}
#endif // !defined(PRODUCT) under this line: Line 4953 in 75e6a74
and then followed the reproduction steps in the issue description, and the output was:
The only noteworthy observation is that the VM isn't supplying an argument for |
I'd say that the throwing one (i.e. the second evaluation) only being given 1 argument instead of 2 is pretty noteworthy? |
I believe that this goes back to #53996 (comment). I added this logging statement: OS::PrintErr("%s\n", js->ToCString()); under this line: Line 3275 in be7a40d
and if I try to evaluate
So this is one of those cases that Alex mentioned in the linked comment where the problem is that "VM currently doesn't have information about variables inside closures which were not captured." |
Repro below (I could not find a way to remove more code than this).
Steps:
b.value2
) and line 8 (inside the closure)b.value2
true
as the result (as expected).CC @DanTup
The text was updated successfully, but these errors were encountered: