* [PATCH] Altering target of named reference when target is initially unset
@ 2024-02-18 4:16 Bart Schaefer
0 siblings, 0 replies; only message in thread
From: Bart Schaefer @ 2024-02-18 4:16 UTC (permalink / raw)
To: Zsh hackers list
[-- Attachment #1: Type: text/plain, Size: 61 bytes --]
This is a bit obscure, but leads to a crash. See test case.
[-- Attachment #2: nameref2unset.txt --]
[-- Type: text/plain, Size: 1264 bytes --]
diff --git a/Src/builtin.c b/Src/builtin.c
index 5c5adb9d3..dd352c146 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2031,8 +2031,10 @@ typeset_single(char *cname, char *pname, Param pm, int func,
char *subscript;
if (pm && (pm->node.flags & PM_NAMEREF) && !((off|on) & PM_NAMEREF)) {
- if (!(off & PM_NAMEREF))
- pm = (Param)resolve_nameref(pm, NULL);
+ if (!(off & PM_NAMEREF)) {
+ if ((pm = (Param)resolve_nameref(pm, NULL)))
+ pname = pm->node.nam;
+ }
if (pm && (pm->node.flags & PM_NAMEREF) &&
(on & ~(PM_NAMEREF|PM_LOCAL|PM_READONLY))) {
/* Changing type of PM_SPECIAL|PM_AUTOLOAD is a fatal error. *
diff --git a/Test/K01nameref.ztst b/Test/K01nameref.ztst
index d8c098a98..ebb70dd92 100644
--- a/Test/K01nameref.ztst
+++ b/Test/K01nameref.ztst
@@ -64,6 +64,17 @@ F:Other type changes are fatal errors, should this also be?
typeset -p ptr var
0:change type of referenced var
>typeset -n ptr=var
+>typeset -t var
+
+ typeset var
+ unset var
+ typeset -n ptr=var
+ typeset -t ptr
+ typeset -p ptr var
+0:change type of unset referenced var
+F:regression - at one time this incorrectly applied the tag to "ptr"
+F:note this causes "var" to become set
+>typeset -n ptr=var
>typeset -t var
typeset -n ptr=var[2]
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-02-18 4:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-18 4:16 [PATCH] Altering target of named reference when target is initially unset Bart Schaefer
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).