diff --git a/ChangeLog b/ChangeLog index 317cc647e..1c93d9fce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 * 54002: Src/parse.c: silence compiler warning for static function diff --git a/Src/params.c b/Src/params.c index 361f173ce..cf6abcf48 100644 --- a/Src/params.c +++ b/Src/params.c @@ -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); diff --git a/Test/K01nameref.ztst b/Test/K01nameref.ztst index 49a9a9d4d..1a41c4756 100644 --- a/Test/K01nameref.ztst +++ b/Test/K01nameref.ztst @@ -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 () {