about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog3
-rw-r--r--Src/params.c10
2 files changed, 11 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 16ede3665..6dc3e32ee 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2024-03-04  Bart Schaefer  <schaefer@zsh.org>
 
+	* unposted (cf. 52617): Src/params.c: only scalars can instantiate
+	a declared named reference
+
 	* 52659: Src/builtin.c, Test/K01nameref.ztst: Fix crash when unset
 	was called on a named referece, add regression test
 
diff --git a/Src/params.c b/Src/params.c
index 263cd0c52..4bcf41c22 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -1050,8 +1050,14 @@ createparam(char *name, int flags)
 			name = refname;
 			oldpm = NULL;
 		    } else {
-			if (!(lastpm->node.flags & PM_READONLY))
-			    lastpm->node.flags |= PM_UNSET;
+			if (!(lastpm->node.flags & PM_READONLY)) {
+			    if (flags) {
+				/* Only plain scalar assignment allowed */
+				zerr("%s: can't change type of named reference",
+				     name);	/* Differs from ksh93u+ */
+				return NULL;
+			    }
+			}
 			return lastpm;
 		    }
 		} else {