Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ebd56e4

Browse files
Help with defdef
1 parent 2a2e053 commit ebd56e4

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)

AltStyle によって変換されたページ (->オリジナル) /