Skip to content

Commit fd42513

Browse files
authored
Backport "fix: report correct location on a repeat modifier" to LTS (#19026)
Backports #17982 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents 5f01616 + 6fb812a commit fd42513

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3028,7 +3028,9 @@ object Parsers {
30283028
val name = in.name
30293029
val mod = atSpan(in.skipToken()) { modOfToken(tok, name) }
30303030

3031-
if (mods.isOneOf(mod.flags)) syntaxError(RepeatedModifier(mod.flags.flagsString))
3031+
if mods.isOneOf(mod.flags) then
3032+
syntaxError(RepeatedModifier(mod.flags.flagsString), mod.span)
3033+
30323034
addMod(mods, mod)
30333035
}
30343036

tests/neg/i17981.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- [E015] Syntax Error: tests/neg/i17981.scala:1:6 ---------------------------------------------------------------------
2+
1 |final final case class Foo() // error
3+
| ^^^^^
4+
| Repeated modifier final
5+
|
6+
| longer explanation available when compiling with `-explain`

tests/neg/i17981.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
final final case class Foo() // error

0 commit comments

Comments
 (0)