Skip to content

Commit 4bb212b

Browse files
committed
Revert "Enable significant indentation after return"
A `return` is not necessarily followed by anything. So our general principles indicate that indentation should not be significant after it, since otherwise an off-by-one-space error could change meaning.
1 parent 7f22c67 commit 4bb212b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ object Tokens extends TokensCommon {
270270
final val closingRegionTokens = BitSet(RBRACE, CASE) | statCtdTokens
271271

272272
final val canStartIndentTokens: BitSet =
273-
statCtdTokens | BitSet(COLONEOL, EQUALS, ARROW, LARROW, WHILE, TRY, FOR, RETURN, IF, WITH)
273+
statCtdTokens | BitSet(COLONEOL, EQUALS, ARROW, LARROW, WHILE, TRY, FOR, IF, WITH)
274274
// `if` is excluded because it often comes after `else` which makes for awkward indentation rules TODO: try to do without the exception
275275

276276
/** Faced with the choice between a type and a formal parameter, the following

docs/docs/reference/other-new-features/indentation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ There are two rules:
2828
class, object, given, or enum definition, in an enum case, or after a package clause, or
2929
- after one of the following tokens:
3030
```
31-
= => <- if then else while do try catch finally for yield match return
31+
= => <- if then else while do try catch finally for yield match
3232
```
3333
If an `<indent>` is inserted, the indentation width of the token on the next line
3434
is pushed onto `IW`, which makes it the new current indentation width.

0 commit comments

Comments
 (0)