-
Notifications
You must be signed in to change notification settings - Fork 1.7k
extension type on a Function named call #55803
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
Comments
I think the analyzer is correct, and the compilers are wrong. Implicit That is: The type See: dart-lang/language#3482, #45551, #54616, #54351 |
Also the following code compiles: extension on String {
void Function() get call => () => print(this);
}
void main() {
'Hello World!'();
} output: Hello World! analyzer errors: The expression doesn't evaluate to a function, so it can't be invoked. • invocation_of_non_function_expression |
I'll also add that this: void main() {
(call: print)('Hello World');
} produces no analyzer warnings, but does not compile: Error: The 'call' property on the record type isn't directly callable but could be invoked by `.call(...)`
(call: print)('Hello World');
^ |
The language team decided to keep the semantics as specified (as mentioned here), that is, implicitly inserted The common front end was changed in https://dart-review.googlesource.com/c/sdk/+/346240 such that the required information is available (that is, backends can make the distinction that some invocations encoded as @johnniwinther, do those changes cover extension typed receivers as well? I'd actually expect the extension type member invocations to be processed early in the compilation pipeline such that later stages would just see an invocation of a function where the syntactic receiver is passed as an actual argument, and this might well eliminate the whole topic of |
We have a lot of parallel code paths to handle the various calls so I would assume we just need to add some missing checks. |
The last one is an analyzer error. A getter named The
The current implementations fails to follow the specification in different ways. I also checked the specification for dynamic function expression invocation. |
Dart SDK version: 3.4.0 (stable) (Mon May 6 07:59:58 2024 -0700) on "windows_x64"
The following program produces errors in the analyzer but compiles and runs successfully:
Edit: more minimal example
output:
Hello Matthew!
analyzer errors:
The expression doesn't evaluate to a function, so it can't be invoked. • invocation_of_non_function_expression
The text was updated successfully, but these errors were encountered: