Skip to content

Commit db19cfd

Browse files
committed
Allow to retract to new column if next token is :
This allows a useful pattern for expressing curried function arguments with `:`. E.g. files.get(fileName).fold: "not found" : f => f.readLine() Without the change here, the second `:` would have to be on the same column as `files`.
1 parent a57134e commit db19cfd

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,18 +539,17 @@ object Scanners {
539539
currentRegion.knownWidth = nextWidth
540540
else if (lastWidth != nextWidth)
541541
errorButContinue(spaceTabMismatchMsg(lastWidth, nextWidth))
542-
currentRegion match {
542+
currentRegion match
543543
case Indented(curWidth, others, prefix, outer)
544544
if curWidth < nextWidth && !others.contains(nextWidth) && nextWidth != lastWidth =>
545-
if (token == OUTDENT)
545+
if token == OUTDENT && next.token != COLON then
546546
errorButContinue(
547547
i"""The start of this line does not match any of the previous indentation widths.
548548
|Indentation width of current line : $nextWidth
549549
|This falls between previous widths: $curWidth and $lastWidth""")
550550
else
551551
currentRegion = Indented(curWidth, others + nextWidth, prefix, outer)
552552
case _ =>
553-
}
554553
end handleNewLine
555554

556555
def spaceTabMismatchMsg(lastWidth: IndentWidth, nextWidth: IndentWidth) =

0 commit comments

Comments
 (0)