Because blerg is indented more than the line containing the most
recent colon, following bar. The desugaring that the programmer
almost certainly intended is this:
foo { bar { baz
quux }
blerg }
This caused problems with line-wrapped conditionals:
if (this
|| that
|| anotherThing):
take
some
actions
Here, take some actions would be interpreted as falling outside the
block, because they are indented less than the layout line, which begins
with || and not if.
The new, simplified layout rule is that all tokens in a layout block
must be indented at least as far as the first token in the block. That
leads naturally to a few legal styles:
// Colons at the end of the line with consistent spacing.
if (quux):
foo
if (bar):
baz
frob
blerg
// Colons before a block with consistent spacing.
if (quux)
: foo
if (bar)
: baz
frob
blerg
// Colons before an aligned block with inconsistent spacing.
if (quux): foo
if (bar): baz
frob
blerg
Previously, this:
Would desugar to this:
Because
blerg
is indented more than the line containing the most recent colon, followingbar
. The desugaring that the programmer almost certainly intended is this:This caused problems with line-wrapped conditionals:
Here,
take some actions
would be interpreted as falling outside the block, because they are indented less than the layout line, which begins with||
and notif
.The new, simplified layout rule is that all tokens in a layout block must be indented at least as far as the first token in the block. That leads naturally to a few legal styles: