about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <schaefer@ipost.com>2020-12-04 16:14:28 -0800
committerBart Schaefer <schaefer@ipost.com>2021-04-13 21:18:35 -0700
commit69bd4a197c0df766d84dcaadbd76bc7a8e94a6ce (patch)
tree354c33b7489f4f814b34b79760d62cfd670949d9
parent733c166115841e42c39a5a11fed0a3e79b12d7d1 (diff)
downloadzsh-69bd4a197c0df766d84dcaadbd76bc7a8e94a6ce.tar.gz
zsh-69bd4a197c0df766d84dcaadbd76bc7a8e94a6ce.tar.xz
zsh-69bd4a197c0df766d84dcaadbd76bc7a8e94a6ce.zip
Final repairs for declared state of tied arrays
Fixups still required in bin_typeset, but assignments to scalar work.
-rw-r--r--Src/builtin.c4
-rw-r--r--Src/params.c5
2 files changed, 7 insertions, 2 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index fff0b641f..8d8ff68e0 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2837,7 +2837,7 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
 	    unqueue_signals();
 	    return 1;
 	} else if (pm) {
-	    if (!(pm->node.flags & PM_UNSET)
+	    if ((!(pm->node.flags & PM_UNSET) || pm->node.flags & PM_DECLARED)
 		&& (locallevel == pm->level || !(on & PM_LOCAL))) {
 		if (pm->node.flags & PM_TIED) {
 		    if (PM_TYPE(pm->node.flags) != PM_SCALAR) {
@@ -2933,7 +2933,7 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
 	if (asg->value.array) {
 	    int flags = (asg->flags & ASG_KEY_VALUE) ? ASSPM_KEY_VALUE : 0;
 	    assignaparam(asg->name, zlinklist2array(asg->value.array, 1), flags);
-	} else /*if (asg0.value.scalar || oldval)*/ {
+	} else if (asg0.value.scalar || oldval) {
 	    /* We have to undo what we did wrong with asg2 */
 	    apm->node.flags &= ~PM_DECLAREDNULL;
 	    if (oldval)
diff --git a/Src/params.c b/Src/params.c
index 1a047d9e0..c09a3eccf 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -4125,6 +4125,11 @@ tiedarrsetfn(Param pm, char *x)
 
     if (*dptr->arrptr)
 	freearray(*dptr->arrptr);
+    else if (pm->ename) {
+	Param altpm = (Param) paramtab->getnode(paramtab, pm->ename);
+	if (altpm)
+	    altpm->node.flags &= ~PM_DECLAREDNULL;
+    }
     if (x) {
 	char sepbuf[3];
 	if (imeta(dptr->joinchar))