Skip to content

fix(interpreter): initialize assoc/indexed arrays for local -A/-a#886

Open
chaliy wants to merge 2 commits intomainfrom
fix/issue-875-assoc-keys-nested-subshell
Open

fix(interpreter): initialize assoc/indexed arrays for local -A/-a#886
chaliy wants to merge 2 commits intomainfrom
fix/issue-875-assoc-keys-nested-subshell

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Mar 27, 2026

Summary

  • local -A m followed by m["a"]="1" produced an indexed array instead of associative, because execute_local_builtin only inserted into call_stack.locals without creating the assoc_arrays entry
  • Initialize the appropriate array type when local -A or -a is used without a compound assignment value
  • Fix applies to both function-scope and global-scope paths
  • Add spec tests assoc_local_declare_then_assign and assoc_local_keys_in_cmdsub

Test plan

  • New spec tests pass
  • All 1812 bash spec tests pass (100%)
  • Full cargo test --all-features passes
  • cargo fmt --check and cargo clippy clean

Closes #875

chaliy added 2 commits March 27, 2026 23:36
…hout value

`local -A m` followed by `m["a"]="1"` produced an indexed array instead
of associative because execute_local_builtin only inserted into
call_stack.locals without creating the assoc_arrays entry.

Initialize the appropriate array type when local -A or -a is used
without a compound assignment value, in both function and global paths.

Closes #875
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Associative array key expansion empty inside process substitution nested in command substitution

1 participant