Skip to content

Commit 78b7629

Browse files
paltherrbartschaefer
authored andcommitted
53796: fix local reference chains and detect self-reference across local scopes
1 parent e1fed54 commit 78b7629

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
omit base level for up-scope references; do not follow reference
1212
chains when computing base level of new references
1313

14+
* Philippe: 53796: Src/params.c, Test/K01nameref.ztst: fix local
15+
reference chains and detect self-reference across local scopes
16+
1417
2025-10-24 Oliver Kiddle <[email protected]>
1518

1619
* 54002: Src/parse.c: silence compiler warning for static function

Src/params.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6412,8 +6412,6 @@ setscope(Param pm)
64126412
stop.name = pm->node.nam;
64136413
stop.value.scalar = NULL;
64146414
stop.flags = PM_NAMEREF;
6415-
if (locallevel && !(pm->node.flags & PM_UPPER))
6416-
stop.flags |= PM_LOCAL;
64176415
dont_queue_signals(); /* Prevent unkillable loops */
64186416
basepm = (Param)resolve_nameref(pm, &stop);
64196417
restore_queue_signals(q);

Test/K01nameref.ztst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,6 +1179,16 @@ F:previously this could create an infinite recursion and crash
11791179
>typeset PS1=zz
11801180
*?*
11811181

1182+
typeset -n ref1
1183+
typeset -n ref2=ref1
1184+
() {
1185+
typeset -n ref3=ref2
1186+
typeset ref2=foo
1187+
ref1=ref3
1188+
}
1189+
1:self reference chain including a hidden reference
1190+
?(anon):3: ref3: invalid self reference
1191+
11821192
zmodload -u zsh/random
11831193
echo z=${(M)${(f)${ zmodload -ap}}:#*SRANDOM*}
11841194
typeset -n ref=SRANDOM

0 commit comments

Comments
 (0)