Subject: Re: zsh -n does not detect incorrect associative array declaration
From: Bart Schaefer <[email-masked]>
To: Zsh hackers list <[email-masked]>
Date: Wed, 23 Mar 2016 19:08:30 -0700
List-Id: Zsh Workers List <zsh-workers.zsh.org>

On Mar 23,  9:23am, Peter Stephenson wrote:
} Subject: Re: zsh -n does not detect incorrect associative array declaratio
}
} 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]= )
} > 
} > forcibly changes the type of "fn" to become an associative array
} 
} Off the original topic, but actually it doesn't, at least not in bash.

I'd forgotten that bash even supports that syntax, but in any case it
does change the type in ksh.

$ typeset -a x
$ typeset -p x
typeset -a x
$ x=( [a]=1 [b]=2 )
$ typeset -p x
typeset -A x=([a]=1 [b]=2)
$ 

Bash allows you to set numerically-indexed positions in a normal array
with the ( [key]=value ) syntax, and also outputs the arrays that way
with "typeset -p".  You can have sparse arrays in bash.