unisonweb / unison

A friendly programming language from the future
https://unison-lang.org
Other
5.81k stars 271 forks source link

Name binding logic doesn't prefer direct deps to indirect deps #5340

Closed mitchellwrosen closed 2 months ago

mitchellwrosen commented 2 months ago

If your namespace contains

my.foo = ...
lib.dep.lib.dep.foo = ...

then a reference to suffix foo should resolve to my.foo (since it's prioritized over indirect dependencies).

And it does:

something = foo + foo -- resolves to my.foo

Unless my.foo is also bound in the file:

my.foo = ...
something = foo + foo -- ambiguous

This is because the suffix foo matches one thing in the file (my.foo) and one thing in the namespace-shadowed-by-file (lib.dep.lib.dep.foo). The name binding logic should note that here too one name should be prioritized over the other.