1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-08-22 18:41:00 +02:00

Partial fix for handling of tied arrays.

As of this commit when a tied array is declared but neither the scalar
nor the array has an initializer, the array is initialized to empty.

The scalar struct param of a tied pair stores a direct pointer to the
internal array value of the array struct param, and upon assignment
modifies it without referring to the containing struct.  This means
that there's no opportunity to clear the PM_DECLAREDNULL bits on both
structs when the scalar is assigned.  Conversely, assigning to the
array does use the struct for the scalar.
This commit is contained in:
Bart Schaefer 2020-12-03 22:30:04 -08:00
parent a8f2a5d0c8
commit 128035c93c

View file

@ -2890,6 +2890,8 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
*
* Don't attempt to set it yet, it's too early
* to be exported properly.
*
* This creates the array with PM_DECLAREDNULL.
*/
asg2.name = asg->name;
asg2.flags = 0;
@ -2933,6 +2935,10 @@ bin_typeset(char *name, char **argv, LinkList assigns, Options ops, int func)
assignaparam(asg->name, zlinklist2array(asg->value.array, 1), flags);
} else if (oldval)
assignsparam(asg0.name, oldval, 0);
else /*if (asg0.value.scalar)*/ {
/* We have to undo what we did wrong with asg2 */
apm->node.flags &= ~PM_DECLAREDNULL;
}
unqueue_signals();
return 0;