Subject: Re: zsh -n does not detect incorrect associative array declaration
From: Peter Stephenson <[email-masked]>
To: Zsh hackers list <[email-masked]>
Date: Wed, 23 Mar 2016 09:23:38 +0000
List-Id: Zsh Workers List <zsh-workers.zsh.org>

On Tue, 22 Mar 2016 23:40:54 -0700
Bart Schaefer <[email-masked]> wrote:
> Contrast this with ksh where associative array assignments look like
> 
> fn=( [foo_key]=foo_val [bar_key]= )
> 
> There the parser doesn't need to know the type of fn because the
> association is explicit in the format of the parenthesized list.  If
> we ever get around to implementing that bit of ksh syntax your
> assertion would become valid.  (But in that case the assignment
> forcibly changes the type of "fn" to become an associative array so
> the typeset is irrelevant.)

Off the original topic, but actually it doesn't, at least not in bash.

$ a=(1 2 3)
$ echo ${a[2]}
3
$ a=([one]=1 [two]=2)
$ echo ${a[*]}
2

This has been interpreted as a[one]=1 then a[two]=2 with "a" still an
array, so "one" and "two" are treated as 0.  This version was quite old
(4.1.7).

pws