Subject: ${#${(A)=name=word}} behavior depends on number of elements
From: Lawrence Velázquez <[email-masked]>
To: [email-masked]
Date: Fri, 12 Aug 2016 18:11:47 -0400
List-Id: Zsh Workers List <zsh-workers.zsh.org>

As I would expect, ${#${(A)=name=word}} expands to the number of
elements in array "foo" after assignment.

	% unset foo; echo ${#${(A)=foo=a 'b c' d}}; typeset foo
	3
	foo=( a 'b c' d )

However, if "foo" ends up with just one element, the expression expands
to the number of characters in that element.

	% unset foo; echo ${#${(A)foo=abc}}; typeset foo    
	3
	foo=( abc )
	% unset foo; echo ${#${(A)=foo=abc}}; typeset foo 
	3
	foo=( abc )
	% unset foo; echo ${#${(A)foo=a b c}}; typeset foo  
	5
	foo=( 'a b c' )
	% unset foo; echo ${#${(A)=foo='a b c'}}; typeset foo
	5
	foo=( 'a b c' )

The behavior is the same for ":=" and "::=".

	% echo $ZSH_PATCHLEVEL
	zsh-5.2-0-gc86c20a
	% setopt
	combiningchars
	extendedhistory
	incappendhistorytime
	interactive
	login
	monitor
	promptsubst
	shinstdin
	zle

vq