exec 2>&1	# to see fatal error messages in proper sequence
unset ax bx oops
oops='this is a problem'
typeset -A ax bx
typeset -a kx=(
  '' '\' '`' '(' '[' ')' ']' '=' '"' "'" '!' '@' '$' '*'
  $'\0' '\\' '\`' '\(' '\[' '\)' '\]' '\=' '\!' '\@' '\$' '\*'
  '()safe' '(r)set' '(R)set' '(k)safe'	# look like valid subscript flags
  '(a' '(a)' '(n:foo:)a' '(n:1)a'	# look like invalid subscript flags
  'set' '"set"' \'set\' '\s\e\t'
  'safe' '"safe"' \'safe\' '\s\a\f\e'
  '\\' '\\\' '\\\\' '""' \'\'
  'two words' 'two  spaces' ' initial space' 'trailing space '
  $'\x80\\' $'\x80\`' $'\x80\~'		# broken UTF-8
  '?~>#'
  '$oops' '${oops}' '"$oops"' '"${(@w)oops"' '${(qqq)oops}' '$(echo oops)'
)
for ((i=0; i<255; i++)); do
  printf -v n '\\x%02x' $i
  eval "kx+=(\$'$n')"
done

for k in "$kx[@]"; do
  ax[$k]=$k
  bx[$k]=$k
done
typeset -p 1 ax
print COUNT: $#ax

print $'\nWith (b)'
for k in "$kx[@]"; do
  ( unset "ax[${(b)k}]" ) && unset "ax[${(b)k}]" &&
  print -r -- ${ax[$k]+Missed} ${(V)ax[$k]-Got $k}
done
typeset -p 1 ax

ax=(${(kv)bx})
print $'\nWith (q)'
for k in "$kx[@]"; do
  ( unset "ax[${(q)k}]" ) && unset "ax[${(q)k}]" &&
  print -r -- ${ax[$k]+Missed} ${(V)ax[$k]-Got $k}
done
typeset -p 1 ax

ax=(${(kv)bx})
print $'\nWith (qq)'
for k in "$kx[@]"; do
  ( unset "ax[${(qq)k}]" ) && unset "ax[${(qq)k}]" &&
  print -r -- ${ax[$k]+Missed} ${(V)ax[$k]-Got $k}
done
typeset -p 1 ax

ax=(${(kv)bx})
print $'\nWith (qqq)'
for k in "$kx[@]"; do
  ( unset "ax[${(qqq)k}]" ) && unset "ax[${(qqq)k}]" &&
  print -r -- ${ax[$k]+Missed} ${(V)ax[$k]-Got $k}
done
typeset -p 1 ax

ax=(${(kv)bx})
print $'\nWithout backslashes'
for k in "$kx[@]"; do
  ( unset "ax[$k]" ) && unset "ax[$k]" &&
  print -r -- ${ax[$k]+Missed} ${(V)ax[$k]-Got $k}
done
typeset -p 1 ax

ax=(${(kv)bx})
print $'\nWith pattern from workers/43269'
for k in "$kx[@]"; do
  ( unset "ax[${(*)k//(#m)[]\\]/\\$MATCH}]" ) &&
  unset "ax[${(*)k//(#m)[]\\]/\\$MATCH}]" &&
  print -r -- ${ax[$k]+Missed} ${(V)ax[$k]-Got $k}
done
typeset -p 1 ax
print COUNT: $#ax
