Skip to content

Commit bc5fe2f

Browse files
committed
Avoid spurious error spans
Parser.syntaxError contains a tweak that underlines the whole span of the current token, if it has a name. Tho make this work reliably we need to reset the name to null when reading a new token, since not every token sets a name.
1 parent 7651df4 commit bc5fe2f

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ object Scanners {
407407
*/
408408
protected final def fetchToken(): Unit = {
409409
offset = charOffset - 1
410+
name = null
410411
(ch: @switch) match {
411412
case ' ' | '\t' | CR | LF | FF =>
412413
nextChar()

tests/neg/trailingCommas.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ trait SimpleExpr { (23, "bar", ) } // error
1818
trait TypeArgs { def f: ValidGeneric[Int, String, ] } // error
1919

2020
trait TypeParamClause { type C[A, B, ] } // error
21-
trait FunTypeParamClause { def f[A, B, ] } // error
21+
trait FunTypeParamClause { def f[A, B, ] } // error // error
2222

2323
trait SimpleType { def f: (Int, String, ) } // error
2424
trait FunctionArgTypes { def f: (Int, String, ) => Boolean } // error

0 commit comments

Comments
 (0)