Skip to content

Commit 388b820

Browse files
authored
Merge pull request #10272 from dotty-staging/fix-#10268
Fix #10268: Stop scanning operator before parsing comment
2 parents 306e4fc + ab70f7c commit 388b820

File tree

4 files changed

+13
-3
lines changed

4 files changed

+13
-3
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -960,8 +960,9 @@ object Scanners {
960960
'|' | '\\' =>
961961
putChar(ch); nextChar(); getOperatorRest()
962962
case '/' =>
963-
if (skipComment()) finishNamed()
964-
else { putChar('/'); getOperatorRest() }
963+
val nxch = lookaheadChar()
964+
if nxch == '/' || nxch == '*' then finishNamed()
965+
else { putChar(ch); nextChar(); getOperatorRest() }
965966
case _ =>
966967
if (isSpecial(ch)) { putChar(ch); nextChar(); getOperatorRest() }
967968
else finishNamed()

tests/neg/i10268.check

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-- [E006] Not Found Error: tests/neg/i10268.scala:2:16 -----------------------------------------------------------------
2+
2 | def test[T] = ?//test // error
3+
| ^
4+
| Not found: ?
5+
6+
longer explanation available when compiling with `-explain`

tests/neg/i10268.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Main {
2+
def test[T] = ?//test // error
3+
}

tests/neg/multiLineOps.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ val x = 1
55
val b1 = {
66
22
77
* 22 // ok
8-
*/*one more*/22 // error: end of statement expected
8+
*/*one more*/22 // error: end of statement expected // error: not found: *
99
} // error: ';' expected, but '}' found
1010

1111
val b2: Boolean = {

0 commit comments

Comments
 (0)