Skip to content

Incorrect "assignment to val" error when assigning to a def #22822

Open
@SethTisue

Description

@SethTisue

(noticed while working on #22671 at a spree)

Minimized code

Welcome to Scala 3.6.4 (17.0.14, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.
                                                                                                    
scala> def x = 3
def x: Int
                                                                                                    
scala> x = 4

Output

-- [E052] Type Error: ----------------------------------------------------------
1 |x = 4
  |^^^^^
  |Reassignment to val x

Expectation

x isn't a val, it's a def, so it's nonsensical for the error to refer to "val x"

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:reportingError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesitype:bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions