Skip to content

Commit 1173fcc

Browse files
committed
Special error message for extension (...) with
1 parent 95437d1 commit 1173fcc

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3619,8 +3619,11 @@ object Parsers {
36193619
isUsingClause(extParams)
36203620
do ()
36213621
leadParamss ++= paramClauses(givenOnly = true, numLeadParams = nparams)
3622-
if in.token == COLON then
3623-
syntaxError("no `:` expected here")
3622+
if in.token == WITH then
3623+
syntaxError(
3624+
i"""No `with` expected here.
3625+
|
3626+
|An extension clause is simply followed by one or more method definitions.""")
36243627
in.nextToken()
36253628
val methods =
36263629
if isDefIntro(modifierTokens) then

tests/neg/extension-colon.check

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/neg/extension-colon.scala

Lines changed: 0 additions & 2 deletions
This file was deleted.

tests/neg/extension-with.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- Error: tests/neg/extension-with.scala:1:19 --------------------------------------------------------------------------
2+
1 |extension (x: Int) with // error
3+
| ^^^^
4+
| No `with` expected here.
5+
|
6+
| An extension clause is simply followed by one or more method definitions.

tests/neg/extension-with.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
extension (x: Int) with // error
2+
def foo = x

0 commit comments

Comments
 (0)