Discussion:
[ast-developers] User-defined type array "mutation" when compound variable members are initalised...
Roland Mainz
2013-07-17 22:36:14 UTC
Permalink
Hi!

----

Below is a testcase which shows some type array "mutation", e.g. the
compound variables inside a type are listed twice:
-- snip --
$ ksh -c 'typeset -T x_t=( integer label=-1 ; compound inqueue=(
empty=false ) outqueue=() ) ; compound c ; x_t -a c.ar=( [1]=(
label=67 inqueue=( empty=true ) outqueue=( processed=false ) ) ) ;
print -v c'
-- snip --

AFAIK it should print...
-- snip --
(
x_t -a ar=(
[1]=(
typeset -l -i label=67
typeset -C inqueue=(
empty=true
)
typeset -C outqueue=(
processed=false
)
)
)
)
-- snip --
... but ast-ksh.2013-06-28 on SuSE 12.3/AMD64/64bit prints this:
-- snip --
(
x_t -a ar=(
[1]=(
typeset -l -i label=67
typeset -C inqueue=(
empty=true
)
typeset -C outqueue
typeset -C inqueue
typeset -C outqueue=(
processed=false
)
)
)
)
-- snip --

Note that "inqueue" and "outqueue" appear twice... ;-(

The same output for associative arrays looks OK:
-- snip --
ksh -c 'typeset -T x_t=( integer label=-1 ; compound inqueue=(
empty=false ) outqueue=() ) ; compound c ; x_t -A c.ar=( [1]=(
label=67 inqueue=( empty=true ) outqueue=( processed=false ) ) ) ;
print -v c'
(
x_t -A ar=(
[1]=(
typeset -l -i label=67
typeset -C inqueue=(
empty=true
)
typeset -C outqueue=(
processed=false
)
)
)
)
-- snip --

... but the output for 3D indexed type arrays is even messed-up worse:
-- snip --
$ ksh -c 'typeset -T x_t=( integer label=-1 ; compound inqueue=(
empty=false ) outqueue=() ) ; compound c ; x_t -a c.ar=( [1][7][22]=(
label=67 inqueue=( empty=true ) outqueue=( processed=false ) ) ) ;
print -v c'
(
x_t -a ar=(
typeset -a [1]=(
typeset -a [7]=(
[22]=(
typeset -C inqueue
typeset -C outqueue=(
processed=false
)
)
)
)
[1]=(
typeset -l -i label=-1
typeset -C inqueue=(
empty=false
)
typeset -C outqueue
)
)
)
-- snip --

----

Bye,
Roland
--
__ . . __
(o.\ \/ /.o) roland.mainz at nrubsig.org
\__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer
/O /==\ O\ TEL +49 641 3992797
(;O/ \/ \O;)
Loading...