Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] Fix crash on unset-through-nameref
- X-seq: zsh-workers 52684
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: [PATCH] Fix crash on unset-through-nameref
- Date: Tue, 5 Mar 2024 08:36:55 +0000
- Archived-at: <https://zsh.org/workers/52684>
- In-reply-to: <CAH+w=7ZY74cEwk_vSupOZMpJiH36nyG5XQ4o+b8MyTgrkV7U_g@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- References: <CAH+w=7ayqWoufueuaHiCzjmzgHtv6VV0m7mEXoHn5nGq4pNOzg@mail.gmail.com> <20240304062914.kn6wquvgog3lefom@chazelas.org> <CAH+w=7b9dcQ4f=71rFZSWBVEJ4bzj7NxzD2-zoj2TkpaCkaCjw@mail.gmail.com> <20240304193409.lv725ah6eifiazzx@chazelas.org> <20240304193641.gdjs7girbrvzxq6j@chazelas.org> <CAH+w=7ZY74cEwk_vSupOZMpJiH36nyG5XQ4o+b8MyTgrkV7U_g@mail.gmail.com>
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