Keep nested self-copies out of unoptimizable-recursion - #1530
Merged
Merged
Conversation
…'s own scope The self-call collection in unoptimizable-recursion.xsl matched every reference to a formation's name anywhere below it, including inside nested methods that build a fresh copy of their owner. Restrict it to calls whose nearest enclosing formation is the one being checked.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The self-call collection in `design/unoptimizable-recursion.xsl` matched every `o` below a formation whose `@base` names that formation, with no regard for how deep it sat. A nested method that builds a fresh copy of its owner — the shape every value object in `objectionary/eo` uses to return a new value — reads the same way at the XPath level as a true recursive call, so it tripped the lint even though dataizing the method never re-enters the owner's φ.
The fix narrows `$calls` to self-calls whose nearest enclosing formation is the one under inspection:
```xsl
<xsl:variable name="calls" select=".//o[eo:is-self-call(string(@base), $name) and not(ancestor::o[eo:test-name(@name)]) and ancestor::o[eo:abstract(.)][1] is current()]"/>
```
A self-call inside a nested formation's own body now belongs to that nested formation, not its owner, so it no longer counts toward the owner's recursion check.
Added a regression pack, `allows-a-nested-method-that-builds-a-new-copy-of-its-owner.yaml`, reproducing the `box`/`plus` shape from the issue. Confirmed it fails against the old XSL and passes against the fix; the full `LtByXslTest` suite (586 tests) passes.
Closes #1528