Commit abff610
authored
fix(interpreter): support recursive function calls inside $() command substitution (#1043)
## Summary
- Fix recursive function calls inside `$()` command substitution that
were silently failing
- Root cause: `expand_command_subs_in_arithmetic` executed `$()` without
saving/restoring interpreter state, causing variable mutations to leak
from subshell scope
- Added save/restore of all mutable interpreter state matching the
existing `CommandSubstitution` handler pattern
## Test plan
- [ ] `recursive_function_command_subst` — factorial(5) = 120
- [ ] `recursive_depth_3` — nested string building via recursion
- [ ] `recursive_cmdsub_var_isolation` — variable mutations inside `$()`
in arithmetic don't leak
- [ ] All 1928 existing bash spec tests pass
Closes #9621 parent c038e85 commit abff610
File tree
2 files changed
+54
-1
lines changed- crates/bashkit
- src/interpreter
- tests/spec_cases/bash
2 files changed
+54
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8371 | 8371 | | |
8372 | 8372 | | |
8373 | 8373 | | |
8374 | | - | |
| 8374 | + | |
| 8375 | + | |
8375 | 8376 | | |
8376 | 8377 | | |
8377 | 8378 | | |
| |||
8382 | 8383 | | |
8383 | 8384 | | |
8384 | 8385 | | |
| 8386 | + | |
| 8387 | + | |
| 8388 | + | |
| 8389 | + | |
| 8390 | + | |
| 8391 | + | |
| 8392 | + | |
| 8393 | + | |
8385 | 8394 | | |
8386 | 8395 | | |
| 8396 | + | |
| 8397 | + | |
| 8398 | + | |
| 8399 | + | |
| 8400 | + | |
| 8401 | + | |
| 8402 | + | |
| 8403 | + | |
8387 | 8404 | | |
8388 | 8405 | | |
8389 | 8406 | | |
| |||
Lines changed: 36 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
0 commit comments