always evaluate block.super even if it is not used #267
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.
Resolves #266
The issue is caused by the fact that we were trying to avoid rendering
block.super
when it is not used in a child template by searching for such variable insideblock
node. The problem is that if inside this node there are other nodes, i.e.{% if %}
then we are not searching inside them. We could potentially search for it recursively, but this can lead to unneeded code and runtime complexity. Instead we can always render it when renderingextend
node.This will come at a cost of possibly unneeded rendering of the block (which still may be cheeper than going through nodes tree searching for it) and any errors in the base block being reported for
{% extends %}
node (see changed test case) instead of{{ block.super }}
.Searching for
block.super
would not work reliably for error reporting any way because we are searching only for first occasion ofblock.super
node, where at runtime actual rendering may be happening in another place (i.e. in a different branch ofif
node).Alternatively we could render the content of
block.super
lazily by storing closure instead of rendered value in the context, but quick change like that resulted in infinite recursion and probably requires more changes to make it work.