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

VM reports NoSuchMethodError : method not found: 'topLevel' when two imported libs provide topLevel #15536

Closed
kevmoo opened this issue Dec 9, 2013 · 5 comments
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. closed-as-intended Closed as the reported issue is expected behavior

Comments

@kevmoo
Copy link
Member

kevmoo commented Dec 9, 2013

  1. import two libraries that both provide 'void topLevel() { ... }'
  2. Create a class Foo with instance method bar that calls topLevel
  3. Notice that Analyzer (in Editor) reports 'topLevel' is defined in lib X and Y.
  4. In a main, create Foo and call foo.bar

Expected: VM yells about ambiguous function definition (like analyzer)

Actual:
    Class 'Foo' has no instance method 'topLevel'.

    NoSuchMethodError : method not found: 'topLevel'
    Receiver: Instance of 'Foo'

@kevmoo
Copy link
Member Author

kevmoo commented Dec 9, 2013

My scenario:

  1. Two libraries: bot and hop
  2. hop imports bot as a dependencies
  3. bot uses hop as a dev dependency to run test tasks, among other things
  4. I'm trying to move a method topoSort from hop to bot
  5. Adding topoSort to bot creates a collision in hop, but I don't see it in the editor...it's not reporting issues with imported libraries
  6. My tests crash claiming topoSort doesn't exist...when really I have 2 (!!!)

@DartBot
Copy link

DartBot commented Dec 9, 2013

This comment was originally written by @mhausner


From the VM's perspective, the NSM is the right behavior. The spec says:

If a name N is referenced by a library L and N is introduced into the top level scope of L by more than one import, and not all the imports denote the same declaration, then:
A static warning occurs.
If N is referenced as a function, getter or setter, a NoSuchMethodError is raised. <<====
If N is referenced as a type, it is treated as a malformed type.


Added AsDesigned label.

@kevmoo
Copy link
Member Author

kevmoo commented Dec 9, 2013

Pushing this to a spec bug

In a world with lots of imported libraries, the chance that a pub update brings in a silent name conflict is huge.

The current error offers little help to end users or library authors.


cc @mhausner.
Removed Area-VM label.
Added Area-Language, Triaged labels.

@gbracha
Copy link
Contributor

gbracha commented Jan 6, 2014

An implementation could choose to define a subclass of NoSuchMethodError, say NoSuchMethodDueToAmbiguityError, that indicated that the method was absent because of an ambiguity . It might even say what the source(s) of ambiguity were.

In other words, there isn't a real need to change the spec (besides, that isn't so easy any more; it will have to pass the standards committee).

And so, I am ping-ponging this back to the VM team.


Removed Area-Language label.
Added Area-VM label.

@DartBot
Copy link

DartBot commented Apr 3, 2015

This comment was originally written by @mhausner


No bug here.


Added AsDesigned label.

@kevmoo kevmoo added Type-Defect area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. closed-as-intended Closed as the reported issue is expected behavior labels Apr 3, 2015
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, FFI, and the AOT and JIT backends. closed-as-intended Closed as the reported issue is expected behavior
Projects
None yet
Development

No branches or pull requests

3 participants