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

Parser bugs: "local a=()"



--Summary--

Zsh parser recognize "local a=()" as a local function named "a=".
Sometimes that causes segmentation fault.

(in Japanese)
http://qiita.com/mpyw/items/e9e4c3b872b30c7024ee

--Version--

zsh 5.0.8 (x86_64-apple-darwin14.3.0)

--Reproduction--

[funcs.zsh]

    func1() {
        a=( )
        b=false
        echo "a in func1 length: ${#a[@]}"
    }
    func2() {
        local a=( )
        local b=false
        echo "a in func2 length: ${#a[@]}"
    }
    func3() {
        a=()
        b=false
        echo "a in func3 length: ${#a[@]}"
    }
    func4() {
        local a=()
        local b=false
        echo "a in func4 length: ${#a[@]}"
    }

[Your shell-session]

    example@local:~$ zsh
    example@local:~$ zsh --version
    zsh 5.0.8 (x86_64-apple-darwin14.3.0)
    example@local:~$ source funcs.zsh
    example@local:~$ func1
    a in func1 length: 0
    example@local:~$ func2
    func2:1: unknown file attribute:
    example@local:~$ func3
    a in func3 length: 0
    example@local:~$ func4
    a in func4 length: 0
    [1]    35208 segmentation fault  zsh



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