Skip to content

Report val reassignment before typecheck errors #16655

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

Closed
soronpo opened this issue Jan 11, 2023 · 0 comments · Fixed by #16660
Closed

Report val reassignment before typecheck errors #16655

soronpo opened this issue Jan 11, 2023 · 0 comments · Fixed by #16660
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc
Milestone

Comments

@soronpo
Copy link
Contributor

soronpo commented Jan 11, 2023

Not a bug, but what I think should be the proper priority of error reporting.
The real issue comes from a large codebase where a x := y operation def is declared.
If the user accidentally forgets to use :, then the compiler goes on ahead and typechecks x = y, even if x is a val, where it can know ahead of time and just report the reassignment to val error instead. The typecheck error can be very confusing where := relies on a typeclass argument.

Compiler version

v3.2.0

Minimized code

val x = "MyString"
x = 5

Output

Found:    (5 : Int)
Required: String

Expectation

I expect the error to be Reassignment to val x.

@soronpo soronpo added the area:reporting Error reporting including formatting, implicit suggestions, etc label Jan 11, 2023
odersky added a commit to dotty-staging/dotty that referenced this issue Jan 11, 2023
little-inferno pushed a commit to little-inferno/dotty that referenced this issue Jan 25, 2023
@Kordyjan Kordyjan added this to the 3.3.0 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:reporting Error reporting including formatting, implicit suggestions, etc
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants