From 0e2af4b7cc7cc42ed28de5efc2dbff7fd355a792 Mon Sep 17 00:00:00 2001 From: bibonix Date: Sun, 26 Apr 2026 16:34:35 +0000 Subject: [PATCH 1/2] Add failing test for redundant-object false positive on self-alias (#639) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reproduces the bug where redundant-object lint incorrectly flags a self-alias ('$ > self') as redundant when it's referenced from a nested formation. The reference 'ξ.ρ.self' from inside say-hello counts as the single usage that triggers the count<=1 threshold. --- .../allows-self-reused-in-nested-formation.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/test/resources/org/eolang/lints/packs/single/redundant-object/allows-self-reused-in-nested-formation.yaml diff --git a/src/test/resources/org/eolang/lints/packs/single/redundant-object/allows-self-reused-in-nested-formation.yaml b/src/test/resources/org/eolang/lints/packs/single/redundant-object/allows-self-reused-in-nested-formation.yaml new file mode 100644 index 000000000..8b89741d3 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/redundant-object/allows-self-reused-in-nested-formation.yaml @@ -0,0 +1,13 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/misc/redundant-object.xsl +asserts: + - /defects[count(defect)=0] +input: | + # Foo. + [] > jeff + $ > self + [] > say-hello + stdout self > @ From f7d52fcf12f370e0ee0ff79ebb971776e24be20e Mon Sep 17 00:00:00 2001 From: bibonix Date: Sun, 26 Apr 2026 16:53:26 +0000 Subject: [PATCH 2/2] Fix #639: don't flag self-aliases used in nested formations MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The redundant-object lint flagged '$ > self' as redundant when the only reference came from a nested formation (e.g. 'ξ.ρ.self' from inside a child object). Inlining '$' into a nested scope changes its meaning, since 'ξ' there refers to the child, not the parent. Skip the check when the candidate's @base is 'ξ' and at least one usage is through a parent hop ('ξ.ρ.…'). --- src/main/resources/org/eolang/lints/misc/redundant-object.xsl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/resources/org/eolang/lints/misc/redundant-object.xsl b/src/main/resources/org/eolang/lints/misc/redundant-object.xsl index 3a09f8775..5a1bf87b0 100644 --- a/src/main/resources/org/eolang/lints/misc/redundant-object.xsl +++ b/src/main/resources/org/eolang/lints/misc/redundant-object.xsl @@ -13,7 +13,8 @@ - + +