diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index 489ee4522453..4c902b0574e2 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -960,8 +960,9 @@ object Scanners { '|' | '\\' => putChar(ch); nextChar(); getOperatorRest() case '/' => - if (skipComment()) finishNamed() - else { putChar('/'); getOperatorRest() } + val nxch = lookaheadChar() + if nxch == '/' || nxch == '*' then finishNamed() + else { putChar(ch); nextChar(); getOperatorRest() } case _ => if (isSpecial(ch)) { putChar(ch); nextChar(); getOperatorRest() } else finishNamed() diff --git a/tests/neg/i10268.check b/tests/neg/i10268.check new file mode 100644 index 000000000000..e08571f7463d --- /dev/null +++ b/tests/neg/i10268.check @@ -0,0 +1,6 @@ +-- [E006] Not Found Error: tests/neg/i10268.scala:2:16 ----------------------------------------------------------------- +2 | def test[T] = ?//test // error + | ^ + | Not found: ? + +longer explanation available when compiling with `-explain` diff --git a/tests/neg/i10268.scala b/tests/neg/i10268.scala new file mode 100644 index 000000000000..e123b2ad4075 --- /dev/null +++ b/tests/neg/i10268.scala @@ -0,0 +1,3 @@ +object Main { + def test[T] = ?//test // error +} \ No newline at end of file diff --git a/tests/neg/multiLineOps.scala b/tests/neg/multiLineOps.scala index 4f48c18af3ce..78a6ba4c3910 100644 --- a/tests/neg/multiLineOps.scala +++ b/tests/neg/multiLineOps.scala @@ -5,7 +5,7 @@ val x = 1 val b1 = { 22 * 22 // ok - */*one more*/22 // error: end of statement expected + */*one more*/22 // error: end of statement expected // error: not found: * } // error: ';' expected, but '}' found val b2: Boolean = {