Skip to content

Fix #637: recognise rho-walking references as void-attr usages#855

Open
bibonix wants to merge 2 commits intoobjectionary:masterfrom
bibonix:fix-637-unused-void-attr-nested-formation
Open

Fix #637: recognise rho-walking references as void-attr usages#855
bibonix wants to merge 2 commits intoobjectionary:masterfrom
bibonix:fix-637-unused-void-attr-nested-formation

Conversation

@bibonix
Copy link
Copy Markdown
Contributor

@bibonix bibonix commented Apr 29, 2026

@yegor256

Closes #637.

Why

The unused-void-attr lint flagged a void attribute as unused even when it was clearly referenced from inside a nested formation. For example:

# Foo.
[widths] > tabular
  [i] > inner
    widths.at i > @

It warned that widths is unused, but widths.at i inside the inner [i] formation is a usage — it just walks back through one ρ hop to reach tabular.

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 i from inside a nested formation).
  • src/test/resources/.../allows-usage-as-nested-rho-ref.yaml — the previously-named catches-usage-as-nested-rho-ref pack was locking in the buggy behaviour, so it is renamed and its assertion flipped: ^.x from a nested formation is a real usage of the outer x.

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 own x as void does not absorb the outer scope’s ξ.ρ.ρ.x.

How verified

Note about CI

The mvn (ubuntu/macos/windows), deep, and reserved jobs are red on this PR, but they have been red on every master commit 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.lintsProgramCorrectly and PkByXslTest.doesNotDuplicateDefectsWhenMultipleDefectsOnTheSameLine. Those failures are not introduced by this change.

bibonix added 2 commits April 29, 2026 04:44
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.
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.

False positive unused-void-attr warning for used attribute

1 participant