Skip to content

Commit e8fb625

Browse files
committed
Allow space tab mismatch when rewritting to indent
1 parent 56bf745 commit e8fb625

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,10 @@ object Parsers {
817817
if enclosingIndent < in.currentRegion.indentWidth then
818818
in.currentRegion.indentWidth
819819
else if
820-
in.token == CASE &&
821-
in.currentRegion.indentWidth == in.currentRegion.enclosing.indentWidth
820+
in.token == CASE && (
821+
in.currentRegion.enclosing == null ||
822+
in.currentRegion.indentWidth == in.currentRegion.enclosing.indentWidth
823+
)
822824
then enclosingIndent
823825
else enclosingIndent.increment
824826
try body

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,8 @@ object Scanners {
643643
currentRegion.knownWidth = nextWidth
644644
else if (lastWidth != nextWidth)
645645
val lw = lastWidth
646-
errorButContinue(spaceTabMismatchMsg(lw, nextWidth))
646+
val msg = spaceTabMismatchMsg(lw, nextWidth)
647+
if rewriteToIndent then report.warning(msg) else errorButContinue(msg)
647648
if token != OUTDENT then
648649
handleNewIndentWidth(currentRegion, _.otherIndentWidths += nextWidth)
649650
if next.token == EMPTY then

0 commit comments

Comments
 (0)