Skip to content

Fix #4934: Issue an error in acceptStatSepUnlessAtEnd #6209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ object Parsers {
case NEWLINE | NEWLINES => in.nextToken()
case SEMI => in.nextToken()
case _ =>
syntaxError("end of statement expected")
in.nextToken() // needed to ensure progress; otherwise we might cycle forever
accept(SEMI)
}
Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i1779.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ object Test {
def f = {
val _parent = 3
q"val hello = $_parent"
q"class $_" // error
q"class $_" // error // error
} // error
}
10 changes: 10 additions & 0 deletions tests/neg/i4934.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
object Foo {
val a = ""); // error: end of statement expected
}
// From #5824:
object Main {
def main(args: Array[String]): Unit = {
val foo = 123 ""; // error: end of statement expected
println(foo)
}
}
2 changes: 1 addition & 1 deletion tests/neg/parser-stability-16.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ class x0[x0] {
val x1 : x0
}
trait x3 extends x0 { // error
x1 = 0 object // error
x1 = 0 object // error // error
// error
2 changes: 1 addition & 1 deletion tests/neg/parser-stability-17.scala
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
trait x0[] { x0: x0 => } // error // error
class x0[x1] extends x0[x0 x0] x2 x0 // error // error
class x0[x1] extends x0[x0 x0] x2 x0 // error // error // error
2 changes: 1 addition & 1 deletion tests/neg/parser-stability-23.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
object i0 {
import Ordering.{ implicitly => } (true: Boolean) match { case _: i1 => true } // error // error
import Ordering.{ implicitly => } (true: Boolean) match { case _: i1 => true } // error // error // error
}
2 changes: 1 addition & 1 deletion tests/neg/parser-stability-4.scala
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
class x0{
def x0: x0 = (x0 => x0) => x0) // error
def x0: x0 = (x0 => x0) => x0) // error // error
// error
14 changes: 7 additions & 7 deletions tests/run/weak-conformance.scala
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ object Test extends App {
locally {
def f(): Int = b + 1
val x1 = if (true) b else if (true) 33 else 5.5 ; x1: Double // b is an inline val
val x2 = if (true) f() else if (true) 33 else 5.5) ; x2: AnyVal // f() is not a constant
val x3 = if (true) 5 else 11L) ; x3: Long
val x4 = if (true) 5 else if (true) 11L else 5.5) ; x4: AnyVal // Long and Double found
val x5 = if (true) 1.0f else 2) ; x5: Float
val x6 = if (true) 1.0f else 1234567890) ; x6: AnyVal // loss of precision
val x7 = if (true) b else if (true) 33 else 'a') ; x7: Char
val x8 = if (true) 5.toByte else 11) ; x8: Byte
val x2 = if (true) f() else if (true) 33 else 5.5 ; x2: AnyVal // f() is not a constant
val x3 = if (true) 5 else 11L ; x3: Long
val x4 = if (true) 5 else if (true) 11L else 5.5 ; x4: AnyVal // Long and Double found
val x5 = if (true) 1.0f else 2 ; x5: Float
val x6 = if (true) 1.0f else 1234567890 ; x6: AnyVal // loss of precision
val x7 = if (true) b else if (true) 33 else 'a' ; x7: Char
val x8 = if (true) 5.toByte else 11 ; x8: Byte
}
}