Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: Disallow array initializer for named reference
On Tue, Jun 10, 2025 at 7:34 AM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>
> With that patch, I get this:
>
> $ typeset -n ref=(var1 var2)
> typeset: -a not allowed with -n
>
> which is a bit confusing as there is no -a.
Debated about this, landed on producing the same output for the same
flavor of discrepancy, but not married to it.
> If I replace your zwarnnam with the zerrnam used for -i
> then I get a similar error message which looks more appropriate:
>
> $ typeset -n ref=(var1 var2)
> typeset: ref: inconsistent type for assignment
So, another conundrum. zerrnam actually sets errflag and kills the
entire context at that point. The "-a not allowed with -n" warning
just returns $? = 1 from typeset without setting errflag. So the
question is whether both or neither should set errflag ... I went with
neither, because after an earlier discussion it was concluded that
this should happen:
% typeset -ailn foo
typeset: -a not allowed with -n
typeset: -i not allowed with -n
typeset: -l not allowed with -n
I'm not wedded to that either, but as it stands the comparison with -i
is not entirely apt, because for most bad flag combinations we
silently discard the nonsensical ones:
% typeset -ai thing
% typeset -p thing
typeset -i thing=0
Messages sorted by:
Reverse Date,
Date,
Thread,
Author