Skip to content

Keep nested self-copies out of unoptimizable-recursion - #1530

Merged
yegor256 merged 1 commit into
masterfrom
claude/lints-issue-1528-c396c7
Oct 2, 2026
Merged

yegor256 merged 1 commit into
masterfrom
claude/lints-issue-1528-c396c7

Conversation

@yegor256

@yegor256 yegor256 commented Oct 2, 2026

Copy link
Copy Markdown
Member

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

…'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.
Copilot AI balanced review requested due to automatic review settings October 2, 2026 10:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@yegor256
yegor256 merged commit 0a245ce into master Oct 2, 2026
24 checks passed
@yegor256
yegor256 deleted the claude/lints-issue-1528-c396c7 branch October 2, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unoptimizable-recursion incorrectly flags non-recursive self-calls in method body

2 participants