-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
SpreeSuitable for a future SpreeSuitable for a future Spreearea:reportingError reporting including formatting, implicit suggestions, etcError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancement
Milestone
Description
Compiler version
3.4.1
Minimized example
//> using scala 3.4.1
object types:
opaque type Struct = Int
val test: Struct = 25
extension (s: Struct)
def field: Int = s
def field_=(other: Int) = ()
@main def hello =
import types.*
test.field = "hello"
Output Error/Warning message
[error] ./test.scala:12:3
[error] Reassignment to val field
[error] test.field = "hello"
[error] ^^^^^^^^^^^^^^^^^^^^
Why this Error/Warning was not helpful
I expected there to be any information about type mismatch in the error message.
-explain doesn't help:
[error] Explanation
[error] ===========
[error] You can not assign a new value to field as values can't be changed.
[error] Keep in mind that every statement has a value, so you may e.g. use
[error] val field = if (condition) 2 else 5
[error] In case you need a reassignable name, you can declare it as
[error] variable
[error] var field = ...
[error] test.field = "hello"
[error] ^^^^^^^^^^^^^^^^^^^^
Metadata
Metadata
Assignees
Labels
SpreeSuitable for a future SpreeSuitable for a future Spreearea:reportingError reporting including formatting, implicit suggestions, etcError reporting including formatting, implicit suggestions, etcbetter-errorsIssues concerned with improving confusing/unhelpful diagnostic messagesIssues concerned with improving confusing/unhelpful diagnostic messagesitype:enhancement