Evaluation order of failing static call #17466
Labels
area-language
Dart language related items (some items might be better tracked at github.com/dart-lang/language).
type-bug
Incorrect behavior (everything from a crash to more subtle misbehavior)
When calling an undefined name in a static context, should the arguments be evaluated before an error is thrown?.
Dart2js and the vm currently disagrees on this:
Example program:
main.dart:
g() {
print("In g()");
}
void main() {
print("In main()");
d(g());
}
> dart main.dart
In main()
Unhandled exception:
<snip>
> dart2js main.dart
main1.dart:10:3:
Warning: Cannot resolve 'd'.
d(g());
> d8 out.js
In main()
In g()
out.js:719: NoSuchMethodError : method not found: 'Symbol("d")'
<snip>
I find the language spec. unclear on this subject. It says (in the section about Unqualified Invocation):
Otherwise [If id is not defined in the scope], if i [the function invocation] occurs inside a top level or static function (be it function, method, getter, or setter) or variable initializer, evaluation of i causes a NoSuchMethodError to be thrown.
This sounds like the arguments will not be evaluated (but is not specific about it), but the constructor of NoSuchMethodError (according to https://api.dartlang.org/apidocs/channels/stable/#dart-core.NoSuchMethodError) takes a list of arguments indicating that the arguments should be known - and therefore evaluated.
Furthermore I guess a function invocation like:
d.a();
where d is an import prefix, and a is not defined in d should behave the same way - the spec is not clear about this either (there is a line in red saying: What about library prefixes?).
The text was updated successfully, but these errors were encountered: