Skip to content

Commit 53a472e

Browse files
committed
Help with defdef
1 parent 5ecf669 commit 53a472e

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4191,6 +4191,10 @@ object Parsers {
41914191
tpt = scalaUnit
41924192
if (in.token == LBRACE) expr()
41934193
else EmptyTree
4194+
else if in.token == IDENTIFIER && paramss.isEmpty && name.endsWith(":") then
4195+
val help = i"; identifier ends in colon, did you mean `${name.toSimpleName.dropRight(1)}`: in backticks?"
4196+
syntaxErrorOrIncomplete(ExpectedTokenButFound(EQUALS, in.token, suffix = help))
4197+
EmptyTree
41944198
else
41954199
if (!isExprIntro) syntaxError(MissingReturnType(), in.lastOffset)
41964200
accept(EQUALS)

tests/neg/i18020b.check

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
-- [E040] Syntax Error: tests/neg/i18020b.scala:4:10 -------------------------------------------------------------------
1010
4 | def g_: Int = 27 // error
1111
| ^^^
12-
| '=' expected, but identifier found
12+
| '=' expected, but identifier found; identifier ends in colon, did you mean `g_`: in backticks?
1313
-- [E040] Syntax Error: tests/neg/i18020b.scala:6:12 -------------------------------------------------------------------
1414
6 | val x_: Int = 1 // error
1515
| ^^^

0 commit comments

Comments
 (0)