Repository navigation
fix(executor): compound element word in bad substitution diagnostics (Refs #3500) - #3621
Merged
Merged
Conversation
…(Refs #3500) A bad substitution inside a compound-assignment element was diagnosed with the `${...}` fragment instead of the element word. GNU quotes the whole element (arrayfunc.c:938-977 over :1108-1129) and reports the word being expanded (subst.c:10278), e.g. `a=([0]=${-x})` -> `\[0\]=${-x}`. Install the element word (quote_assign mirror) as the pending diagnostic word at the two element-expansion sites; assoc elements name the bare value (arrayfunc.c:594-599/:630). A declare-assoc thread-local hint (DECLARE_ASSOC_HINT + RAII guard, installed by the declare_assoc_operand_names() scan in command_prepare.rs) covers the `declare -A` command-word expansion path, which runs before the declare builtin. Bare (eval-argument) flatten installs no word: documented residual, not fixed here. Pin: tests/issue3500_compound_elem_diag_word.rs (19 cells; fail-first 8 red on base, 19/19 on head; lib bilateral 1247 passed / 0 failed both sides; RUSTFLAGS="-D warnings" check clean; cargo fmt clean). NOTE: commit body reconstructed by the continuation lane from REPORT §6/§9.2; the original brief text was unrecoverable. Captain: please amend before merge if the wording needs it.
Member
Author
|
Captain review: PASS (reviewer-run legs, spot-checked by the captain from the raw logs).
Merge round notes: intersection vs live tip |
caomengxuan666
marked this pull request as ready for review
November 14, 2026 17:03
This was referenced Nov 14, 2026
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.
Summary
A bad substitution inside a compound-assignment element was diagnosed with the
${...}fragment instead of the element word. GNU quotes the whole element and reports the word being expanded, e.g.a=([0]=${-x})→\[0\]=${-x}.Root cause
subscripted_parameter_elementhands the RHS towhole_word_parameter_single_value, whosehas_word_operatorarm misjudges${-x}(emptyvar_nameat position 0) and expands it standalone with no pending diagnostic word installed, soexpand_braced_parameter_wordfalls back to the synthesized${-x}fragment. The plain-element path had the same gap (the walker default names the raw token, withoutquote_assign's\[sub\]quoting).Fix
compound_element_diag_word(module level, mirrors GNUquote_assign): indexed[sub]=value→\[sub\]=value; assoc elements → the bare value; a quoted value keeps the fragment's own word.subscripted_parameter_element,compound_plain_element_value[_fields]), install-if-absent.assocparameter is threaded throughexpand_compound_positional_at_assignment[_bare](4 call sites), computed by newcompound_assignment_is_assoc(liveASSOC_VARSmarking OR the declare-assoc hint).DECLARE_ASSOC_HINT+ RAII guard), installed by thedeclare_assoc_operand_names()scan incommand_prepare.rs, covering thedeclare -Acommand-word expansion path, which runs before the declare builtin.GNU anchors:
arrayfunc.c:557/:581/:594-599/:606/:630/:938-977/:1108-1129;subst.c:10278.Regression pin
tests/issue3500_compound_elem_diag_word.rs— 19 cells (10 fix shapes + 6 guard shapes + 2 quiet guards + 1 first-bad-wins). Expectations verified against GNU bash 5.3.20.Verification (continuation lane, base
11719895)Some("${-x}")where the element word is expected.git stash poprestored the tree byte-identical (sha256 verified).cargo build --bin rubashRC=0.RUSTFLAGS="-D warnings" cargo checkRC=0;cargo fmt --checkRC=0.continuation.rsuntouched.本 PR 删除了什么
Nothing — purely additive fix plus the new regression pin. No code, test, file, or behaviour removed.
Note: the commit body was reconstructed by the continuation lane from REPORT §6/§9.2 (the original brief text was unrecoverable); captain, please amend if the wording needs it.
UNVERIFIED-BY-CAPTAIN