Commit 342724a
authored
fix(interpreter): initialize assoc/indexed arrays for local -A/-a (#886)
## 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
- [x] New spec tests pass
- [x] All 1812 bash spec tests pass (100%)
- [x] Full `cargo test --all-features` passes
- [x] `cargo fmt --check` and `cargo clippy` clean
Closes #8751 parent a0588db commit 342724a
File tree
2 files changed
+41
-1
lines changed- crates/bashkit
- src/interpreter
- tests/spec_cases/bash
2 files changed
+41
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4353 | 4353 | | |
4354 | 4354 | | |
4355 | 4355 | | |
| 4356 | + | |
| 4357 | + | |
| 4358 | + | |
| 4359 | + | |
| 4360 | + | |
4356 | 4361 | | |
4357 | 4362 | | |
4358 | 4363 | | |
| |||
4437 | 4442 | | |
4438 | 4443 | | |
4439 | 4444 | | |
4440 | | - | |
| 4445 | + | |
| 4446 | + | |
| 4447 | + | |
| 4448 | + | |
| 4449 | + | |
| 4450 | + | |
| 4451 | + | |
4441 | 4452 | | |
4442 | 4453 | | |
4443 | 4454 | | |
| |||
Lines changed: 29 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
173 | 173 | | |
174 | 174 | | |
175 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
176 | 205 | | |
177 | 206 | | |
178 | 207 | | |
| |||
0 commit comments