Skip to content

Report val reassignment before typecheck errors #16655

Closed
@soronpo

Description

@soronpo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:reportingError reporting including formatting, implicit suggestions, etc

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions