From 735da571e4d9d2c904c6fb5fe4d608b7491c274f Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 16 Nov 2020 11:45:51 +0100 Subject: [PATCH] Fix #9790: Update indentation spec to match observed behavior I added the clause 2. An `` is inserted at a line break, if - ... - the last token on the previous line is not one of the following tokens which indicate that the previous statement continues: ``` then else do catch finally yield match ``` I tried to do without the added clause but lots of tests break. To verify, set Tokens.statCtdTokens to BitSet() and observe the breakage. --- docs/docs/reference/other-new-features/indentation.md | 5 +++++ tests/neg/i9790.scala | 7 +++++++ 2 files changed, 12 insertions(+) create mode 100644 tests/neg/i9790.scala diff --git a/docs/docs/reference/other-new-features/indentation.md b/docs/docs/reference/other-new-features/indentation.md index cc90ca8a1abc..18f00b5407d8 100644 --- a/docs/docs/reference/other-new-features/indentation.md +++ b/docs/docs/reference/other-new-features/indentation.md @@ -74,6 +74,11 @@ There are two rules: - the first token on the next line has an indentation width strictly less than the current indentation width, and + - the last token on the previous line is not one of the following tokens + which indicate that the previous statement continues: + ``` + then else do catch finally yield match + ``` - the first token on the next line is not a [leading infix operator](../changed-features/operators.html). diff --git a/tests/neg/i9790.scala b/tests/neg/i9790.scala new file mode 100644 index 000000000000..3417c4b2c7b0 --- /dev/null +++ b/tests/neg/i9790.scala @@ -0,0 +1,7 @@ +object A: + def fn: Unit = + if true then + println(1) + println(2) // error: start of line does not match previous indentation widths + else + println(2) \ No newline at end of file