Commit 4d514d2
feat(interpreter): implement declare -n nameref variables (#255)
## Summary
- Implement `declare -n` nameref variables that act as aliases for other
variable names
- Add `resolve_nameref()` with chain following (max 10 levels) to
prevent infinite loops
- Integrate nameref resolution into variable expansion and assignment
paths
## Changes
- `crates/bashkit/src/interpreter/mod.rs`: Parse `-n` flag, store
`_NAMEREF_<name>` markers, add `resolve_nameref()`, integrate into
`expand_variable()` and `set_variable()`
- `crates/bashkit/tests/spec_cases/bash/declare.test.sh`: 6 new spec
tests (basic, assign-through, chain, function param, read-unset,
reassign-target)
- `specs/009-implementation-status.md`: Update test counts (declare
10→16, Bash 887→893, Total 1305→1311)
## Test plan
- [x] `cargo test --all-features` passes
- [x] `cargo fmt --check` clean
- [x] `cargo clippy --all-targets --all-features -- -D warnings` clean
- [x] All 6 nameref spec tests pass
- [x] Existing declare tests still pass (no regressions)
Co-authored-by: Claude <noreply@anthropic.com>1 parent ca21002 commit 4d514d2
File tree
3 files changed
+100
-7
lines changed- crates/bashkit
- src/interpreter
- tests/spec_cases/bash
- specs
3 files changed
+100
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3859 | 3859 | | |
3860 | 3860 | | |
3861 | 3861 | | |
| 3862 | + | |
3862 | 3863 | | |
3863 | 3864 | | |
3864 | 3865 | | |
| |||
3871 | 3872 | | |
3872 | 3873 | | |
3873 | 3874 | | |
3874 | | - | |
| 3875 | + | |
| 3876 | + | |
3875 | 3877 | | |
3876 | 3878 | | |
3877 | 3879 | | |
| |||
4015 | 4017 | | |
4016 | 4018 | | |
4017 | 4019 | | |
| 4020 | + | |
| 4021 | + | |
| 4022 | + | |
| 4023 | + | |
4018 | 4024 | | |
4019 | 4025 | | |
4020 | 4026 | | |
| |||
4037 | 4043 | | |
4038 | 4044 | | |
4039 | 4045 | | |
4040 | | - | |
| 4046 | + | |
| 4047 | + | |
| 4048 | + | |
| 4049 | + | |
4041 | 4050 | | |
4042 | 4051 | | |
4043 | 4052 | | |
| |||
5616 | 5625 | | |
5617 | 5626 | | |
5618 | 5627 | | |
| 5628 | + | |
| 5629 | + | |
5619 | 5630 | | |
5620 | 5631 | | |
5621 | | - | |
| 5632 | + | |
5622 | 5633 | | |
5623 | 5634 | | |
5624 | 5635 | | |
5625 | 5636 | | |
5626 | 5637 | | |
5627 | | - | |
| 5638 | + | |
| 5639 | + | |
| 5640 | + | |
| 5641 | + | |
| 5642 | + | |
| 5643 | + | |
| 5644 | + | |
| 5645 | + | |
| 5646 | + | |
| 5647 | + | |
| 5648 | + | |
| 5649 | + | |
| 5650 | + | |
| 5651 | + | |
| 5652 | + | |
| 5653 | + | |
| 5654 | + | |
| 5655 | + | |
5628 | 5656 | | |
5629 | 5657 | | |
5630 | 5658 | | |
| 5659 | + | |
| 5660 | + | |
| 5661 | + | |
5631 | 5662 | | |
5632 | 5663 | | |
5633 | 5664 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
| 110 | + | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
163 | | - | |
| 163 | + | |
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
| |||
0 commit comments