Better handling of leading infix operators in indented code #11959
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In this code, the last
|| !x
was seen as a part of the previous case, so the code was parsed asThis is highly surprising and unintuitive. The fix will insert an
<outdent>
token insteadif the leading infix operator is too far to the left. Too far means: (1) left of the current indentation
region, (2) and not to the right of any outer indentation widths.
(2) allows to still parse code like this
Here, the width of the indentation region after
then
is 4, but the+
operator is to the rightof the outer indentation width of 0., so the indentation region is not closed. In other words,
we do not close an indentation region if the result would not be legal, since it matches none of
the previous indentation widths.