-
Couldn't load subscription status.
- Fork 1.1k
Closed
Labels
area: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
Description
Compiler version
3.7.2
Minimized code
//> using scala 3.7.2
trait Special[A]
object syntax:
given Special[Option[Long]] = ???
given Special[Option[Int]] = ???Output
-- [E120] Naming Error: --------------------------------------------------------
3 | given Special[Option[Int]] = ???
| ^
|Double definition:
|final lazy given val given_Special_Option: Special[Option[Long]] in object syntax at line 2 and
|final lazy given val given_Special_Option: Special[Option[Int]] in object syntax at line 3
1 error foundWhy this Error/Warning was not helpful
The error says what is wrong, but doesn't mention that it is due to design decision in Scala 3 compiler nor provides a workaround, not even with "-explain-types" flag. It leaves user with no help and user might introduce extra objects to put givens in different scopes.
Suggested improvement
As per #23831, the "short names" are by design, and expected solution is to use @targetName("xxx") annotations.
It could be made more helpful if error message would explicitly suggest to use @targetName annotations for custom name provisions.
Metadata
Metadata
Assignees
Labels
area: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