Repository navigation
fix(executor): treat prefixed array storage as an array, completing #755 (#755, #758) - #786
Merged
Merged
Conversation
(#755, #758) PR #785 typed the array-vs-scalar verdict (`parameter_is_array_variable`) but missed the prefixed-storage case: `local v=("${foo[@]}")` / `declare d=("${foo[@]}")` render `\u{1d}([0]=...)` while the ARRAY mark lands late, so the copy collapsed into a single element holding the whole storage render (a regression in the merged #785 — `command_chaining::part_003::test_local_compound_array_assignment_preserves_quoted_array_at`). The STORAGE_WORD_PREFIX is an UNAMBIGUOUS array marker (a scalar value never carries it), so it is now accepted; the bare `(a b c)` shape that #755 is about deliberately stays a scalar. Adds the declared-compound-copy guard to tests/issue755_scalar_array_expansion.rs. Refs #755. Fixes #758.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #755. Fixes #758.
This completes the work merged as #785. That PR typed the array-vs-scalar verdict (
Executor::parameter_is_array_variable) so a scalar whose text looks like(a b c)is no longer re-parsed as a list, and made malformed parameter expansions reportbad substitutionwith the whole word and status 1 (instead of an empty string with status 0). Both behaviours are inmasterand verified byte-for-byte against WSL GNU Bash 5.3.0.What this follow-up fixes
#785's typing missed the prefixed-storage case.
local v=("${foo[@]}")anddeclare d=("${foo[@]}")render the array as\u{1d}([0]=...)before the ARRAY mark lands, so the copy collapsed into a single element holding the whole storage render:This was caught by a pre-existing test that regressed:
command_chaining::part_003::test_local_compound_array_assignment_preserves_quoted_array_at(confirmed failing onmasterand fixed here;part_003passes again).The
STORAGE_WORD_PREFIXis an unambiguous array marker — a scalar value never carries it — so it is now accepted alongside the ARRAY/ASSOC mark tables, the structured cell, and the dynamic-array registry. The BARE(a b c)shape that #755 is about deliberately stays a scalar (the prefix arm is the only addition; the bare-paren arm ofis_array_storageis not reintroduced).Verification
wsl bash /mnt/c/...): scalar[@]/[*]/[i]/${#x}/slices/keys, every[@]/[*]operator and@A/@atransform form, the(a b c)-element genuine array, and the a malformed parameter expansion is silently swallowed: wrong value, no diagnostic, status 0 (breaks set -e / && / ||) #758 malformed-name/whole-word/set -eshapes.tests/issue755_scalar_array_expansion.rsnow has 11 tests (added the declared-compound-copy guard) andtests/issue758_bad_substitution_status.rshas 8; all pass.cargo fmt --checkclean.issue154,issue298_299,issue311,issue337_342,issue532,issue533,issue536,issue539,issue631,issue636,issue638,issue639,array_compound_quote_regressions,array_store_parity,assignment_quote_roundtrip_regressions,o1_parse_expand_exec_regressions,parameter_transform_tests.Residual (out of scope)
command_chaining::part_071::test_shellmath_decimal_divide_script_path,part_080::test_unclosed_arithmetic_subscript_does_not_execute_tail_bracket,part_005/part_031/part_043, and thecli_tests/regressionfailures are pre-existing onmasterin this environment (path translation, missingthird_party/bash/tests, Windows signal/fd handling) —part_080was confirmed failing on a pristineorigin/masterworktree.