summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Src/params.c2
-rw-r--r--Test/K01nameref.ztst10
3 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 5854f4250..317cc647e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -11,6 +11,9 @@
omit base level for up-scope references; do not follow reference
chains when computing base level of new references
+ * Philippe: 53796: Src/params.c, Test/K01nameref.ztst: fix local
+ reference chains and detect self-reference across local scopes
+
2025-10-24 Oliver Kiddle <opk@zsh.org>
* 54002: Src/parse.c: silence compiler warning for static function
diff --git a/Src/params.c b/Src/params.c
index 6945e73e9..361f173ce 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -6412,8 +6412,6 @@ setscope(Param pm)
stop.name = pm->node.nam;
stop.value.scalar = NULL;
stop.flags = PM_NAMEREF;
- if (locallevel && !(pm->node.flags & PM_UPPER))
- stop.flags |= PM_LOCAL;
dont_queue_signals(); /* Prevent unkillable loops */
basepm = (Param)resolve_nameref(pm, &stop);
restore_queue_signals(q);
diff --git a/Test/K01nameref.ztst b/Test/K01nameref.ztst
index b03487d03..49a9a9d4d 100644
--- a/Test/K01nameref.ztst
+++ b/Test/K01nameref.ztst
@@ -1179,6 +1179,16 @@ F:previously this could create an infinite recursion and crash
>typeset PS1=zz
*?*
+ typeset -n ref1
+ typeset -n ref2=ref1
+ () {
+ typeset -n ref3=ref2
+ typeset ref2=foo
+ ref1=ref3
+ }
+1:self reference chain including a hidden reference
+?(anon):3: ref3: invalid self reference
+
zmodload -u zsh/random
echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*}
typeset -n ref=SRANDOM