1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-11-23 01:31:27 +01:00

53797: fix creation of undeclared target variable through reference chain

This commit is contained in:
Philippe Altherr 2025-10-26 17:11:32 -07:00 committed by Bart Schaefer
parent 78b7629361
commit 7546c18076
3 changed files with 18 additions and 1 deletions

View file

@ -14,6 +14,9 @@
* Philippe: 53796: Src/params.c, Test/K01nameref.ztst: fix local
reference chains and detect self-reference across local scopes
* Philippe: 53797: Src/params.c, Test/K01nameref.ztst: fix creation
of undeclared target variable through reference chain
2025-10-24 Oliver Kiddle <opk@zsh.org>
* 54002: Src/parse.c: silence compiler warning for static function

View file

@ -1048,7 +1048,7 @@ createparam(char *name, int flags)
(oldpm = upscope(oldpm, oldpm->base))) {
Param lastpm;
struct asgment stop;
stop.flags = PM_NAMEREF | (flags & PM_LOCAL);
stop.flags = PM_NAMEREF;
stop.name = oldpm->node.nam;
stop.value.scalar = GETREFNAME(oldpm);
lastpm = (Param)resolve_nameref(oldpm, &stop);

View file

@ -1179,6 +1179,20 @@ F:previously this could create an infinite recursion and crash
>typeset PS1=zz
*?*
unset var1 var2
typeset -n ref1=var1
() {
typeset -n ref2=ref1
typeset -n ref1=var2
typeset -i ref2=42
typeset -p ref1 ref2 var1 var2
}
1:typeset reference chain to not-yet-defined variable including a hidden reference
?(anon):typeset:4: no such variable: var2
>typeset -n ref1=var2
>typeset -n ref2=ref1
>typeset -i var1=42
typeset -n ref1
typeset -n ref2=ref1
() {