Skip to content

Commit bace3e6

Browse files
authoredJun 16, 2021
Merge pull request #12801 from dotty-staging/fix-12757
Don't insert semicolons in conditions unless indented
2 parents 2911aab + 0e94917 commit bace3e6

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed
 

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

+5-4
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ object Parsers {
7272
if source.isSelfContained then new ScriptParser(source)
7373
else new Parser(source)
7474

75-
private val InCase: Region => Region = Scanners.InCase.apply
76-
private val InCond: Region => Region = Scanners.InBraces.apply
75+
private val InCase: Region => Region = Scanners.InCase(_)
76+
private val InCond: Region => Region = Scanners.InParens(LPAREN, _)
77+
private val InFor : Region => Region = Scanners.InBraces(_)
7778

7879
abstract class ParserCommon(val source: SourceFile)(using Context) {
7980

@@ -167,7 +168,7 @@ object Parsers {
167168
class Parser(source: SourceFile)(using Context) extends ParserCommon(source) {
168169

169170
val in: Scanner = new Scanner(source)
170-
// in.debugTokenStream = true // uncomment to see the token stream of the standard scanner, but not syntax highlighting
171+
//in.debugTokenStream = true // uncomment to see the token stream of the standard scanner, but not syntax highlighting
171172

172173
/** This is the general parse entry point.
173174
* Overridden by ScriptParser
@@ -2553,7 +2554,7 @@ object Parsers {
25532554
if (in.token == INDENT)
25542555
inBracesOrIndented(enumerators())
25552556
else {
2556-
val ts = inSepRegion(InCond)(enumerators())
2557+
val ts = inSepRegion(InFor)(enumerators())
25572558
if (rewriteToOldSyntax(Span(start)) && ts.nonEmpty)
25582559
if (ts.head.sourcePos.startLine != ts.last.sourcePos.startLine) {
25592560
patch(source, Span(forEnd), " {")

‎tests/pos/i12757.scala

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
val x = Some(10)
2+
3+
def f =
4+
if x.exists
5+
(x => x == 10) then
6+
println("Yes")
7+
else
8+
println("No")

0 commit comments

Comments
 (0)