Fix #4564: indent closes implicit object #4570
Merged
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.
Fixes #4564
The breaking example from that issue was:
The general case is when an implicit object is followed by an indent, eg this also breaks:
The solution was to make implicit objects act more like implicit calls as far as how they behave when they see an
INDENT. Basically the exception to them behaving the same is when theINDENTfollows the:of an object key (at which point clearly anINDENTshould not close the implicit object). Otherwise they should behave the same and this allows us to close multiple open implicit calls and/or implicit objects when we see anINDENT(like in the first example)To make implicit objects act more like implicit calls, we need to push
CONTROLs (ie suppressors ofINDENT-closes-implicits behavior) onto thestacknot just when we're (immediately) inside an implicit call (ieinImplicitCall()) but also when we're (immediately) inside an implicit object (ieinImplicitObject())This led to a slightly cleaner solution to handle things like
a: for x in y then xthan what @xixixao did in #3328. Basically if we see aFORright after a:, we explicitly push aCONTROL(rather than having a special case represented by@insideForDeclarationthat thwarts attemptedendImplicitObject()s, that's whatCONTROLis there to do). So I was able to get rid of all the@insideForDeclarationstuff from that PR@GeoffreyBooth if this is deemed potentially-breaking I can retarget it to
2