Skip to content

fix(unset): expanded-to-empty subscript unsets element 0 - #1010

Merged
caomengxuan666 merged 1 commit into
masterfrom
fix/unset-empty-subscript
Oct 22, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
fix/unset-empty-subscript

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Closes #1009. GNU arrayfunc.c:1141 unbind_array_element -> array_expand_index (arrayfunc.c:1356) -> expr.c:417 evalexp -> subexpr (empty -> 0, valid): unset 'a[$j]' with empty $j unsets element 0; scalar 'v[$j]' unbinds the whole variable (subscript 0 IS the variable, arrayfunc.c:1218-1231). Caller-decides fix mirroring the assoc arm's raw-vs-expanded pattern: Empty with literally-empty raw stays the silent no-op (both shells keep the var/element); expanded-to-empty maps to 0. Assoc/literal/write paths untouched (verified identical). Tests: lib 693 + unset/nameref cli green; 13/13 upstream suites byte-identical vs base; GNU parity scripts match.

@caomengxuan666
caomengxuan666 merged commit 87dd973 into master Oct 22, 2026
8 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/unset-empty-subscript branch October 22, 2026 10:10
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.

[bug] unset 'a[$j]' with empty $j leaves a[0] in place

1 participant