Closed IsaacOscar closed 1 year ago
I think that the example should be rejected because a double opening brace is more likely to be a typo than to be deliberate. A block containing nothing but a block is very occasionally useful (I’ve used it once), but can be accommodated with more clarity using extra lines and extra indentation.
If others disagree and we decide to change the indentation rules, then we need a better change than the one proposed above, because the proposed change leaves the “otherwise” situation undefined.
I believe that the current indentation rules are fine. In the more than three years that this issue has been open, no one has proposed better rules. I have no problem with adding a sentence to the spec highlighting that this is deliberate, but don't think that it warrants too much ink.
Spec updated with counter-example in commit 2a83d19
Consider the following pointless code:
I have in fact tried to write code like that in grace (where an if statement returns a block).
In minigrace this produces an error:
However, in kernan it runs as expected.
From the spec, I see two relavent rules (emphasis mine)
It seems in the line
}} else {{
, the first closing brace satisfies the first part of rule 4, however the second one contradicts the second part, since the line it is on is not indendented enough. I suggest deleting the "otherwise" clause from rule 4, and adding the folowing bolded text to rule 3.Or if you think that my example should be rejected (why?) add a clarfication to the spec that this is intended; because it's quite subtle why this code violates the rules.