Closed nafg closed 6 months ago
Apparently, it's always been like that...
Welcome to Scala 2.12.8 (OpenJDK 64-Bit Server VM, Java 1.8.0_352).
Type in expressions for evaluation. Or try :help.
scala> object O { val a = 1 }
defined object O
scala> import O.{a, a}
<console>:12: error: a is renamed twice
import O.{a, a}
^
...and always will! [evil cackle]
-- [E122] Syntax Error: ------------------------------------------------------------------------------------------------
1 |import O.{a, a}
| ^
| a is renamed twice on the same import line.
1 error found
The ancient behavior survived refactoring (which is correct for a refactor).
But the useful check is that a name is not introduced twice.
This is perfectly fine:
import x.{toString, toString => show}
except for the subsequent ambiguity for toString
.
The spec does not disallow foolish imports.
I suppose one could argue that all imports are just a rename from the fully qualified one to the unprefixed one...
On Tue, Jun 27, 2023, 12:36 PM som-snytt @.***> wrote:
The ancient behavior survived refactoring (which is correct for a refactor).
But the useful check is that a name is not introduced twice.
This is perfectly fine:
import x.{toString, toString => show}
except for the subsequent ambiguity for toString.
The spec does not disallow foolish imports.
— Reply to this email directly, view it on GitHub https://github.com/scala/bug/issues/12813#issuecomment-1609871271, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAYAUAJWXXL6635JUPWNVLXNMDZBANCNFSM6AAAAAAZU6PLD4 . You are receiving this because you authored the thread.Message ID: @.***>
Indeed, the spec says import x.a
is shorthand for import x.{a => a}
, and that's the underlying cause for the odd wording.
Reproduction steps
Scala version: 2.13.11
Problem
It's not renamed at all