Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] Fix crash on unset-through-nameref



2024-03-04 15:50:45 -0800, Bart Schaefer:
> On Mon, Mar 4, 2024 at 11:36 AM Stephane Chazelas <stephane@xxxxxxxxxxxx> wrote:
> >
> > The other one is now wrong in a different way:
> >
> > $ ./Src/zsh -c 'f() { typeset -n v=$1; unset v; typeset -p w; v=(a b); }; w=1; f w; typeset -p w'
> > typeset -a w=( a b )
> > $ ./Src/zsh -c 'f() { typeset -n v=$1; unset v; typeset -p w; v=(a b); }; v=1; w=1; f w; typeset -p w'
> > $
> 
> Src/zsh -c 'f() { typeset -n v=$1; unset v; typeset -p w; v=(a b) ||
> echo failed; }; v=1; w=1; f w; typeset -p w'
> failed
> 
> So removing the PM_DECLARED is hiding the "attempt to assign array
> value to non-array" message but still not permitting the assignment.
> 
> This probably is not better than the previous situation.

But it works in:

$ zsh -c 'a=0; f() { local a=1; a[2]=(foo bar); typeset -p a; }; f; typeset -p a'
f: a: attempt to assign array value to non-array
$ zsh -c 'a=0; f() { local a=1; unset -v a; a[2]=(foo bar); typeset -p a; }; f; typeset -p a'
typeset -a a=( '' foo bar )
typeset a=0

Where we should also have a variable after that unset that is not
set but "declared" without any type (not in the global scope
though), suggesting the problem may be fixable.

-- 
Stephane




Messages sorted by: Reverse Date, Date, Thread, Author