Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Typeset with array

On Jun 25, 10:29am, Peter Stephenson wrote:
} > Bash allows array element assignments:
} >   typeset var[4]=hello
} > Zsh now prints "can't create local array elements"
} > Including when not in a function.
} The problem isn't the assignment but you haven't yet told the shell that
} "var" is a (local?) variable or what type it is.

Some quick tests:

torch% typeset var var[2]=two 
torch% typeset -p var
typeset var=two
torch% typeset -a array array[2]=two
typeset: array[2]: inconsistent type for assignment
torch% typeset -p array
typeset -a array
torch% typeset newarray=() newarray[2]=two 
zsh: segmentation fault (core dumped)  Src/zsh -f

#0  0x080bce65 in prefork (list=0x0, flags=2) at ../../zsh-5.0/Src/subst.c:58
#1  0x0806ab0f in execcmd (state=0xbff08f60, input=0, output=0, how=18, 
    last1=2) at ../../zsh-5.0/Src/exec.c:3586
#2  0x08065b69 in execpline2 (state=0xbff08f60, pcode=131, how=18, input=0, 
    output=0, last1=0) at ../../zsh-5.0/Src/exec.c:1718
#3  0x08064f08 in execpline (state=0xbff08f60, slcode=9218, how=18, last1=0)
    at ../../zsh-5.0/Src/exec.c:1501
#4  0x080647a8 in execlist (state=0xbff08f60, dont_change_job=0, exiting=0)
    at ../../zsh-5.0/Src/exec.c:1277
#5  0x0806418e in execode (p=0xb7d68798, dont_change_job=0, exiting=0, 
    context=0x8149bb3 "toplevel") at ../../zsh-5.0/Src/exec.c:1074
#6  0x08080819 in loop (toplevel=1, justonce=0) at ../../zsh-5.0/Src/init.c:207
#7  0x08083c48 in zsh_main (argc=2, argv=0xbff090b4)
    at ../../zsh-5.0/Src/init.c:1675
#8  0x0804c2ea in main (argc=2, argv=0xbff090b4) at ../../zsh-5.0/Src/main.c:93

Messages sorted by: Reverse Date, Date, Thread, Author