Skip to content

Commit 7546c18

Browse files
paltherrbartschaefer
authored andcommitted
53797: fix creation of undeclared target variable through reference chain
1 parent 78b7629 commit 7546c18

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
* Philippe: 53796: Src/params.c, Test/K01nameref.ztst: fix local
1515
reference chains and detect self-reference across local scopes
1616

17+
* Philippe: 53797: Src/params.c, Test/K01nameref.ztst: fix creation
18+
of undeclared target variable through reference chain
19+
1720
2025-10-24 Oliver Kiddle <[email protected]>
1821

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

Src/params.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,7 @@ createparam(char *name, int flags)
10481048
(oldpm = upscope(oldpm, oldpm->base))) {
10491049
Param lastpm;
10501050
struct asgment stop;
1051-
stop.flags = PM_NAMEREF | (flags & PM_LOCAL);
1051+
stop.flags = PM_NAMEREF;
10521052
stop.name = oldpm->node.nam;
10531053
stop.value.scalar = GETREFNAME(oldpm);
10541054
lastpm = (Param)resolve_nameref(oldpm, &stop);

Test/K01nameref.ztst

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

1182+
unset var1 var2
1183+
typeset -n ref1=var1
1184+
() {
1185+
typeset -n ref2=ref1
1186+
typeset -n ref1=var2
1187+
typeset -i ref2=42
1188+
typeset -p ref1 ref2 var1 var2
1189+
}
1190+
1:typeset reference chain to not-yet-defined variable including a hidden reference
1191+
?(anon):typeset:4: no such variable: var2
1192+
>typeset -n ref1=var2
1193+
>typeset -n ref2=ref1
1194+
>typeset -i var1=42
1195+
11821196
typeset -n ref1
11831197
typeset -n ref2=ref1
11841198
() {

0 commit comments

Comments
 (0)