-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Name binding is not as ambiguous as specified #8059
Comments
Is this the behavior of scalac or something written down in the spec somewhere ? |
Spec is at https://scala-lang.org/files/archive/spec/2.13/02-identifiers-names-and-scopes.html It's fixed in 2.13.1, but as someone noted, no one writes code like that. |
The linked Scala 2 PR has the two tests that should have ambiguous references. From the OP, it looks like Dotty behavior changed, because the second test picks
The first test still compiles in Dotty and still picks
|
What? In the absence of Contrary to whatever that guy tried last summer, test 2 is the same result. I hope he doesn't think I'm trying to "show him up" or make him look stupid. Oh, did you try 2.13.10? Let me try that. Yes, 2.13 correctly reports the ambiguity. But Scala 3 has a very simple and pleasant mechanism for ranking the bindings. Maybe it's simple enough for you to understand and maybe diagnose the issue. OK, I'll give a shot in the new year. |
Periodic ticket validation, as dotty typer still has code from 2016 claiming that scala 2 doesn't follow the spec. Also #17439 is unresolved.
|
minimized code
Given a compilation unit:
Either of these references to
X
should be ambiguous:or
Compilation output
It compiles on both Scala 2.13.0 and 3, but Scala 2 picks
p.q.X
andp.r.X
respectively, and Dotty picksp.X
in both cases.expectation
p.q.X
has lowest precedence: it is made available by the packagingpackage q
but cannot shadow the high priority definitionp.X
, and is therefore ambiguous.Similarly for the
import r.X
, as imports never shadow definitions in the current file.The text was updated successfully, but these errors were encountered: