Skip to content

Fix #10268: Stop scanning operator before parsing comment #10272

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
Nov 11, 2020
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
5 changes: 3 additions & 2 deletions compiler/src/dotty/tools/dotc/parsing/Scanners.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 6 additions & 0 deletions tests/neg/i10268.check
Original file line number Diff line number Diff line change
@@ -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`
3 changes: 3 additions & 0 deletions tests/neg/i10268.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
object Main {
def test[T] = ?//test // error
}
2 changes: 1 addition & 1 deletion tests/neg/multiLineOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down