Skip to content

Commit cdb6250

Browse files
authored
Merge pull request #6209 from dotty-staging/fix-#4934
Fix #4934: Issue an error in acceptStatSepUnlessAtEnd
2 parents 7ed9a69 + 40020f3 commit cdb6250

File tree

8 files changed

+23
-12
lines changed

8 files changed

+23
-12
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ object Parsers {
341341
case NEWLINE | NEWLINES => in.nextToken()
342342
case SEMI => in.nextToken()
343343
case _ =>
344+
syntaxError("end of statement expected")
344345
in.nextToken() // needed to ensure progress; otherwise we might cycle forever
345346
accept(SEMI)
346347
}

tests/neg/i1779.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ object Test {
88
def f = {
99
val _parent = 3
1010
q"val hello = $_parent"
11-
q"class $_" // error
11+
q"class $_" // error // error
1212
} // error
1313
}

tests/neg/i4934.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
object Foo {
2+
val a = ""); // error: end of statement expected
3+
}
4+
// From #5824:
5+
object Main {
6+
def main(args: Array[String]): Unit = {
7+
val foo = 123 ""; // error: end of statement expected
8+
println(foo)
9+
}
10+
}

tests/neg/parser-stability-16.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ class x0[x0] {
22
val x1 : x0
33
}
44
trait x3 extends x0 { // error
5-
x1 = 0 object // error
5+
x1 = 0 object // error // error
66
// error

tests/neg/parser-stability-17.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
trait x0[] { x0: x0 => } // error // error
2-
class x0[x1] extends x0[x0 x0] x2 x0 // error // error
2+
class x0[x1] extends x0[x0 x0] x2 x0 // error // error // error

tests/neg/parser-stability-23.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
object i0 {
2-
import Ordering.{ implicitly => } (true: Boolean) match { case _: i1 => true } // error // error
2+
import Ordering.{ implicitly => } (true: Boolean) match { case _: i1 => true } // error // error // error
33
}

tests/neg/parser-stability-4.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class x0{
2-
def x0: x0 = (x0 => x0) => x0) // error
2+
def x0: x0 = (x0 => x0) => x0) // error // error
33
// error

tests/run/weak-conformance.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ object Test extends App {
4242
locally {
4343
def f(): Int = b + 1
4444
val x1 = if (true) b else if (true) 33 else 5.5 ; x1: Double // b is an inline val
45-
val x2 = if (true) f() else if (true) 33 else 5.5) ; x2: AnyVal // f() is not a constant
46-
val x3 = if (true) 5 else 11L) ; x3: Long
47-
val x4 = if (true) 5 else if (true) 11L else 5.5) ; x4: AnyVal // Long and Double found
48-
val x5 = if (true) 1.0f else 2) ; x5: Float
49-
val x6 = if (true) 1.0f else 1234567890) ; x6: AnyVal // loss of precision
50-
val x7 = if (true) b else if (true) 33 else 'a') ; x7: Char
51-
val x8 = if (true) 5.toByte else 11) ; x8: Byte
45+
val x2 = if (true) f() else if (true) 33 else 5.5 ; x2: AnyVal // f() is not a constant
46+
val x3 = if (true) 5 else 11L ; x3: Long
47+
val x4 = if (true) 5 else if (true) 11L else 5.5 ; x4: AnyVal // Long and Double found
48+
val x5 = if (true) 1.0f else 2 ; x5: Float
49+
val x6 = if (true) 1.0f else 1234567890 ; x6: AnyVal // loss of precision
50+
val x7 = if (true) b else if (true) 33 else 'a' ; x7: Char
51+
val x8 = if (true) 5.toByte else 11 ; x8: Byte
5252
}
5353
}

0 commit comments

Comments
 (0)