Repro
A function body containing two or more consecutive blocks of local -A NAME; NAME=(...) (zsh-style declare-and-populate of an associative array) causes the parser to misattribute the closing ) of a later array literal to the function body. Subsequent local calls inside the function are then reported as out-of-function, and the function appears to terminate early.
Reduced repro lives in the allowlist entry for git.zsh. Minimal shape:
function myfn() {
local -A first
first=( 'A ' 'foo' )
local -A second
second=( 'B ' 'bar' )
}
Surfaced by: tests/real_world/corpus/zsh/oh-my-zsh/git.zsh (function _omz_git_prompt_status, lines 42-145, which has three consecutive declare-and-populate blocks).
Observed
error[E1001]: expected 'RBRACE', got 'EOF' reported on the line containing the second ), then cascading 'local can only be used in a function' errors on lines that ARE inside the function.
Expected
Function parses to completion; ) of each array literal closes only that literal.
Repro
A function body containing two or more consecutive blocks of
local -A NAME; NAME=(...)(zsh-style declare-and-populate of an associative array) causes the parser to misattribute the closing)of a later array literal to the function body. Subsequentlocalcalls inside the function are then reported as out-of-function, and the function appears to terminate early.Reduced repro lives in the allowlist entry for
git.zsh. Minimal shape:Surfaced by:
tests/real_world/corpus/zsh/oh-my-zsh/git.zsh(function_omz_git_prompt_status, lines 42-145, which has three consecutive declare-and-populate blocks).Observed
error[E1001]: expected 'RBRACE', got 'EOF'reported on the line containing the second), then cascading 'local can only be used in a function' errors on lines that ARE inside the function.Expected
Function parses to completion;
)of each array literal closes only that literal.