-
Notifications
You must be signed in to change notification settings - Fork 1.1k
maybe warn when "forward reference to a local variable" is shadowing parameter. #14401
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
Comments
this also fails in the same way in Scala 2, so it might be expected, i.e. it doesn't matter what the function parameter is called because line 3 defines def f(dkfhsdkj: Int) = {
val b = a + 1
val a = 3
b
} |
Since last year, Scala 2 tells you where the reference refers to. The similar example (from 2012) at
In solidarity with OP, I too expected a lint for the shadowing. Either I'm remembering a previous speculative conversation about such a lint, or (note to self) just the last tweak to name binding, where an inherited member must not shadow a definition in outer scope. A linting addendum would be extra: This issue also recalls that people expect to have a syntax to refer to a shadowed parameter, similar to selection from |
changed this issue to be about producing warning specifically when there is this forward reference error and the forward reference matches the name of a parameter |
Shadowing warnings are very hard to get right in all cases. In this case it seems the forward reference error is indication enough of what goes on. |
Compiler version
3.1.1
Minimized code
Output
Expectation
I would expect to receive a
5
. Maybe a warning about shadowing.I do not expect a compilation error.
Notes
I initially thought that this was a problem of top level definitions, so I tried
obtaining the same error.
The text was updated successfully, but these errors were encountered: