Repository navigation
fix(executor): exempt funsub bodies from bad-substitution scan - #3869
Merged
Merged
Conversation
…3502) Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Member
Author
|
【j1 续作报告】#3855 funsub 回归修复 — 已合入(mergeCommit 5f6fb63) 机制: 验证腿:
相邻残差(未动,供队长知悉): |
caomengxuan666
added a commit
that referenced
this pull request
Nov 17, 2026
… the scan can own (Refs #3864) The #3855 pre-scan gate judges every ${...} inner as a braced name and reports the scan's whole word with status 1, but GNU's bad substitution default (subst.c:10276-10288) reports the WORD BEING EXPANDED with the error class of the context. The scan may only emit that verdict when it coincides with the real expansion's, so the gate now defers to the real expansion when (a) the word is a compound assignment value — GNU expands elements individually (arrayfunc.c:557) and names the element word, which the scan's whole-word display cannot name (issue3500); (b) the name head is a $'...' literal the real expansion decodes — subst.c:7583 judges the extracted NAME (issue2650); (c) the verdict is POSIX-fatal — subst.c:10285-10286 FORCE_EOF when POSIX + non-interactive + compat > 43, which status 1 cannot express (audit B4-F08). All seven #3502 pins and the #3869 funsub pins are preserved by construction: no deferral fires on their words. UNVERIFIED-BY-CAPTAIN: no build/test executed in this lane (build chain down); head census re-run parked for the captain.
caomengxuan666
added a commit
that referenced
this pull request
Nov 18, 2026
… the scan can own (Refs #3864) ## Summary Refs #3864. PR #3855 added a `braced_name_is_bad_substitution(inner)` check to the `parameter_expansion_error_in_word_context` pre-scan so a bad substitution inside a ` :?` message word surfaces as the inner error (rubash#3502: `${v:?${-x}}` prints only `${-x}: bad substitution`). The check judges the whole `${...}` inner as a braced name and reports the scan's whole word with status 1 — but the scan may only emit that verdict when it coincides with what the real expansion would report. Where it does not, the scan pre-empts the correct diagnostic: - Compound assignment values (issue3500, whole stem): GNU expands elements individually (`arrayfunc.c:557 expand_compound_array_assignment`) and the diagnostic names the element word (`\\[0\\]=${-x}`); the scan names the raw parenthesised value. - `$'name'` extquote names (issue2650): `subst.c:7583 valid_brace_expansion_word` judges the extracted NAME; the real expansion decodes `$'x1'` to `x1` in a quoted context, where the gate on the raw literal misjudges it. - POSIX fatal class (audit B4-F08): `subst.c:10285-10288` makes a bad substitution FORCE_EOF when POSIX + non-interactive + compat > 43; the scan's status 1 downgrades it to DISCARD. The funsub faces (issue2763/issue2761/issue3092/issue3823, golden_funsub_valsub, the arithmetic-for CLI case) are already fixed by #3869, which exempts funsub bodies at the top of this same scan loop; this PR does not touch that exemption. ## Repair The gate now fires only when the scan's verdict coincides with the real expansion's: it defers (returns nothing, letting the real expansion report) when any of these holds — 1. the scanned word is (or contains) a compound assignment value (parser compound marker, or a leading `(`): GNU's diagnostic is per-element, which the scan's whole-word display cannot name; 2. the span's name head is a `$'...'` literal that `resolve_dollar_quoted_parameter_name` decodes: the gate must judge the decoded name; 3. the POSIX-fatal predicate holds (POSIX mode, non-interactive, `compatibility_level > 43`, mirroring the fatal arm in `command_execute.rs`): the scan's status 1 cannot express FORCE_EOF. Everything else is unchanged: the gate still fires for bare bad names (`${-x}`, `${}`, `${(M)y}`), still pre-empts a later `:?` error left-to-right, and still fires inside `:?`/`:-` operator-word recursions — so all seven #3502 pins and the #3869 funsub pins keep passing by construction. ## What this PR removes Nothing from the product surface: the #3855 gate check stays; only its three over-broad firing slices are deferred to the real expansion. No new diagnostic text, no new error class. ## Validation **UNVERIFIED-BY-CAPTAIN** — no build or test was executed in this lane: the build chain is down (X299 tunnel refused, Simular box wallet empty, local build banned: MemAvailable ~503M, below the 1.5G gate). `cargo test` / `cargo check` / lib+base alignment / `RUSTFLAGS="-D warnings"` check are all parked; the captain re-runs the head census after the chain recovers. - New nails `tests/issue3864_parameter_errors_regression.rs` (11 tests): issue3500 element words (indexed/assoc/nested/valid guard), issue2650 extquote top-level + bare forms, POSIX fatal + compat43 guard, funsub-valsub shapes, #3502 inner-only + pin-7 ordering guards. Written fail-first, before the repair; fail-first is by code analysis, not execution (see above). - GNU oracle probes (local `/bin/bash` 5.2.21; stems already carry 5.3.20 verification): `"[${$'x1'}]"` -> `[hello]`; `a=([0]=${-x})` -> `\\[0\\]=${-x}: bad substitution` rc 1; POSIX `echo ${}` -> fatal, no ALIVE, rc 1; `${v:?${-x}}` -> only `${-x}: bad substitution` rc 1. - `rustfmt --check` clean on both touched files. - Evaluation note: reverting #3855 outright was considered and rejected — it would reopen #3502 (7 pins). The scoped repair keeps #3502 green while clearing the mechanically attributable clusters. Three singles in #3864 (issue2029, issue2771, issue2761 x2) have no `${` span in their scripts that can trip the gate, so no `parameter_errors.rs` change can clear them; they are recorded in the lane REPORT as unattributed (likely census flakes / other-window commits) for the captain's census re-run to confirm. ## Captain review (PASS, merged) Original head 19159b6, captain-extracted from its CI logs: census total 79 (era baseline), issue3500 19/19, own pins issue3864 11/11, goldens exactly the two baseline names; the darwin leg was cancelled with zero steps (never ran, not a red). Merge-shape head 0a73b4f (update-branch over master 0863639; the only master-side touch of parameter_errors.rs since the merge-base was PR #3871's +6/-2 arith-label hunk near line 1417, ~1000 lines from this PR's hunks), captain-extracted: - issue3500 19/19 PASS, issue3864 11/11 PASS, issue2650 10/10, issue2763 6/6, issue201 2/2, issue2771 5/5, audit stems 40/40. - Census total 81, goldens exactly the two baseline names. - Two non-blocking cells, both adjudicated churn: the CLI leg's sole failure is c_command_keeps_named_coproc_output_fds_distinct (2 PASS / 2 FAIL across four era heads, uncorrelated with any diff), and census cell issue2029 head_pipe_fold_leaves_the_remainder is FAIL here but PASS on both the original head and on PR #3870's head (which carries #3855 without this fix) — not owned by this change. Fail-first basis (stated honestly): the lane's 11 pins were written pre-fix but not executed pre-fix (no build route); their fail-first rests on code analysis, corroborated by the tip census showing the same shapes red before this PR and green after. What this removes: the unscoped #3855 gate call in parameter_expansion_error_in_word_context — the scan emitted whole-word status-1 verdicts for compound values, $'...' name heads and the POSIX-fatal class. It is replaced by the deferral-aware gate; each deferral restores the pre-#3855 behavior for that slice. No other behavior is deleted.
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
innerbraced_name_is_bad_substitutiongate to the parameter-error pre-scan (parameter_expansion_error_in_word_context). It fires on${ cmd; }funsub bodies (case x in x) esac;,echo 4;), which GNU never routes throughparameter_brace_expand:param_expand'scase LBRACE(subst.c:10775-10798) sends${+FUNSUB_CHAR (parser.h:85) tofunction_substitute(subst.c:6917) first, sovalid_brace_expansion_word(subst.c:10053 -> 7583) never sees them.funsub_introducer+extract_funsub_body+funsub_body_is_terminated, mirroring expand_word.rs / embedded_parameters.rs) and skips the parameter battery for them, advancing past the funsub's own extent. Introducer-led spans that fail admission still fall through to the parameter checks.tests/issue3502_funsub_bad_substitution_scan.rs(9 tests) covering the i1-audit reproducer, assignment RHS, operator-word nesting (:-/:?), embedded/double-quoted/}-word-text/tab/newline-introducer forms, plus bad-substitution guards.Refs #3502
Test plan
cargo test --test issue3502_funsub_bad_substitution_scan— 9/9 (fail-first on master: 8/9 red)cargo test --test issue3502_question_error_bad_substitution_word— 7/7 (fix(executor): ${v:?${-x}} reports only the nested bad substitution #3855 pins stay green)cargo test --test cli_tests arithmetic_for— 5/5 (2 audit regressions green)cargo test --test regression golden_funsub_valsub— 1/1RUSTFLAGS="-D warnings" cargo checkclean; rustfmt clean; marker-lint + utf8-hygiene clean${ }empty-body gap (unrelated to this change)Generated with Devin