Enable break and continue tags to work in eager execution #1269
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.
Handles the
{% continue %}and{% break %}tags in eager execution.There are 4 situations considered, each of them tested via a separate test:
The break tag is easiest to handle. We can simply use the
EagerGenericTagwrapper. If aDeferredValueExceptionis thrown when evaluating the BreakTag, then it will be reconstructed. This works for both flattened for-loops (because a{% for __ignored__ in [0] %}wrapper is already added to preserve the scope, meaning when the break tag is hit, it will break out of the single-level for-loop) and for deferred for loops.The continue tag is a bit trickier because it wouldn't work in a flattened for loop as it would effectively become a
{% break %}:Instead, when encountering a
{% continue %}tag that must be deferred, we'll reconstruct it and mark the for loop that it's currently in as deferred (as we don't know if it would continue or not after that). Omitting this step is basically an optimization for the{% break %}tag because it functions the same in a flattened or a deferred for-loop.