Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 28e072e

Browse files
committed
Help with defdef
1 parent 6a497d7 commit 28e072e

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
@@ -4113,6 +4113,10 @@ object Parsers {
41134113
tpt = scalaUnit
41144114
if (in.token == LBRACE) expr()
41154115
else EmptyTree
4116+
else if in.token == IDENTIFIER && paramss.isEmpty && name.endsWith(":") then
4117+
val help = i"; identifier ends in colon, did you mean `${name.toSimpleName.dropRight(1)}`: in backticks?"
4118+
syntaxErrorOrIncomplete(ExpectedTokenButFound(EQUALS, in.token, suffix = help))
4119+
EmptyTree
41164120
else
41174121
if (!isExprIntro) syntaxError(MissingReturnType(), in.lastOffset)
41184122
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)