Skip to content

Commit 81fb624

Browse files
committed
Migrate the dollar check
1 parent bae7646 commit 81fb624

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

compiler/src/dotty/tools/dotc/config/MigrationVersion.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ enum MigrationVersion(val warnFrom: SourceVersion, val errorFrom: SourceVersion)
3434
case GivenSyntax extends MigrationVersion(future, future)
3535
case ImplicitParamsWithoutUsing extends MigrationVersion(`3.7`, future)
3636
case Scala2Implicits extends MigrationVersion(future, future)
37+
case IdentifierDollars extends MigrationVersion(`3.8`, `3.9`)
3738

3839
require(warnFrom.ordinal <= errorFrom.ordinal)
3940

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,11 +1301,11 @@ object Parsers {
13011301
val start = in.sourcePos()
13021302
ident().tap: name =>
13031303
if checkable && name.toSimpleName.contains('$') then
1304-
report.error(IllegalIdentifier(name), start)
1304+
report.errorOrMigrationWarning(IllegalIdentifier(name), start, MigrationVersion.IdentifierDollars)
13051305

13061306
extension (nameTree: NameTree) def checkName: nameTree.type =
13071307
if !isBackquoted(nameTree) && nameTree.name.toSimpleName.contains('$') then
1308-
report.error(IllegalIdentifier(nameTree.name), nameTree.srcPos)
1308+
report.errorOrMigrationWarning(IllegalIdentifier(nameTree.name), nameTree.srcPos, MigrationVersion.IdentifierDollars)
13091309
nameTree
13101310

13111311
/** Accept identifier and return Ident with its name as a term name. */

tests/neg/i18234.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//> using options -source:3.9
12
/* vals */
23
val goodVal = 1
34
val $startVal = 1 // error

0 commit comments

Comments
 (0)