Fix #637: recognise rho-walking references as void-attr usages#855
Open
bibonix wants to merge 2 commits intoobjectionary:masterfrom
Open
Fix #637: recognise rho-walking references as void-attr usages#855bibonix wants to merge 2 commits intoobjectionary:masterfrom
bibonix wants to merge 2 commits intoobjectionary:masterfrom
Conversation
The unused-void-attr lint emits a false-positive warning when a void attribute of an outer formation is referenced from a nested inner formation, because the inner reference is parsed as ξ.ρ.<attr> and the current XSL only matches ξ.<attr> substrings.
The unused-void-attr lint matched only literal 'ξ.<attr>' substrings,
which made every reference from inside a nested formation
('ξ.ρ.<attr>', 'ξ.ρ.ρ.<attr>', ...) invisible to the lint and produced
a false 'unused' warning for the outer void attribute.
The XSL now matches any '^ξ(.ρ)*.<attr>(...)?$' base, counts the rho
hops, and confirms that the formation declaring the attribute is
exactly that many enclosing abstract scopes above the usage.
The existing pack 'catches-usage-as-nested-rho-ref' was locking in the
buggy behaviour; it is renamed to 'allows-usage-as-nested-rho-ref' and
its assertion flipped to the correct expectation.
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.
@yegor256
Closes #637.
Why
The
unused-void-attrlint flagged a void attribute as unused even when it was clearly referenced from inside a nested formation. For example:It warned that
widthsis unused, butwidths.at iinside the inner[i]formation is a usage — it just walks back through oneρhop to reachtabular.The XSL only checked for the literal substring
ξ.<attr>in@base, so any reference parsed asξ.ρ.<attr>,ξ.ρ.ρ.<attr>, etc. slipped past it.How
src/main/resources/org/eolang/lints/misc/unused-void-attr.xsl— match^ξ(.ρ)*.<attr>(...)?$, count theρhops, and confirm that the formation declaring the attribute is exactly that many enclosing abstract scopes above the usage. References that walk past the formation, or that resolve into a different scope, still leave the attribute flagged as unused.src/test/resources/.../allows-void-attr-used-in-nested-formation.yaml— new regression test covering the bug from the issue (widths.at ifrom inside a nested formation).src/test/resources/.../allows-usage-as-nested-rho-ref.yaml— the previously-namedcatches-usage-as-nested-rho-refpack was locking in the buggy behaviour, so it is renamed and its assertion flipped:^.xfrom a nested formation is a real usage of the outerx.All the existing shadowing tests (
catches-unused-void-attribute-with-same-named-formation,catches-unused-void-attribute-horizontally-with-same-name,catches-void-with-same-name-in-canonical,catches-unused-void-attr) keep passing, because rho-walking is structural rather than name-based: an inner formation that declares its ownxas void does not absorb the outer scope’sξ.ρ.ρ.x.How verified
mvn -B test -Dtest=LtByXslTest#testsAllLintsByEo— 345 packs pass, 1 skipped (unchanged).Source(...).defects(...)on the snippet from False positiveunused-void-attrwarning for used attribute #637: nounused-void-attrwarning is emitted any more.Note about CI
The
mvn (ubuntu/macos/windows),deep, andreservedjobs are red on this PR, but they have been red on everymastercommit since 2026-04-26 (last green run #2202 on 2026-04-24). I confirmed locally that the same two tests time out on plain master too:MonoLintsTest.lintsProgramCorrectlyandPkByXslTest.doesNotDuplicateDefectsWhenMultipleDefectsOnTheSameLine. Those failures are not introduced by this change.