Skip to content
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

Evaluation order of failing static call #17466

Closed
sigurdm opened this issue Mar 13, 2014 · 2 comments
Closed

Evaluation order of failing static call #17466

sigurdm opened this issue Mar 13, 2014 · 2 comments
Assignees
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)

Comments

@sigurdm
Copy link
Contributor

sigurdm commented Mar 13, 2014

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?).

@srawlins
Copy link
Member

srawlins commented Jun 8, 2014

This is essentially a dupe of Issue #17382

@gbracha
Copy link
Contributor

gbracha commented Aug 27, 2014

There are a number of issues with this section.


Set owner to @gbracha.
Added Accepted label.

@sigurdm sigurdm added Type-Defect area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). labels Aug 27, 2014
@kevmoo kevmoo added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed priority-unassigned labels Feb 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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)
Projects
None yet
Development

No branches or pull requests

5 participants