From 73fa419a3ee2df74d4fb805117ec078d3ed58074 Mon Sep 17 00:00:00 2001 From: Yegor Bugayenko Date: Fri, 2 Oct 2026 13:12:33 +0300 Subject: [PATCH] fix(#1528): limit unoptimizable-recursion self-calls to the formation'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. --- .../eolang/lints/design/unoptimizable-recursion.xsl | 2 +- ...ed-method-that-builds-a-new-copy-of-its-owner.yaml | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/org/eolang/lints/packs/single/unoptimizable-recursion/allows-a-nested-method-that-builds-a-new-copy-of-its-owner.yaml diff --git a/src/main/resources/org/eolang/lints/design/unoptimizable-recursion.xsl b/src/main/resources/org/eolang/lints/design/unoptimizable-recursion.xsl index 7cab376a3..ddabded37 100644 --- a/src/main/resources/org/eolang/lints/design/unoptimizable-recursion.xsl +++ b/src/main/resources/org/eolang/lints/design/unoptimizable-recursion.xsl @@ -92,7 +92,7 @@ - + diff --git a/src/test/resources/org/eolang/lints/packs/single/unoptimizable-recursion/allows-a-nested-method-that-builds-a-new-copy-of-its-owner.yaml b/src/test/resources/org/eolang/lints/packs/single/unoptimizable-recursion/allows-a-nested-method-that-builds-a-new-copy-of-its-owner.yaml new file mode 100644 index 000000000..4e5597b84 --- /dev/null +++ b/src/test/resources/org/eolang/lints/packs/single/unoptimizable-recursion/allows-a-nested-method-that-builds-a-new-copy-of-its-owner.yaml @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: Copyright (c) 2016-2026 Objectionary.com +# SPDX-License-Identifier: MIT +--- +sheets: + - /org/eolang/lints/design/unoptimizable-recursion.xsl +defects: 0 +input: | + [x] > box + x > @ + [y] > plus + box y > @