Repository navigation
locale funnel: cover array binding channels and the declare hack (W-LOCALE) - #3242
Merged
Merged
Conversation
The funnel itself (src/locale.rs, sv_locale at variables.c:6272 via get_string_value at variables.c:2495) already projects arrays to element 0 and assocs to the "0" key; three caller-side mechanism gaps kept whole binding channels from ever reaching it, or reached it before the array marks existed: - The assignment store's early-return arms (element assignment via assign_array_element, scalar-over-indexed-array, scalar-over-assoc at variables.c:3128-3142) completed binds without the generic tail's funnel note. Note the funnel at each arm's store point: one bind, one note, recorded at the execution store layer (the discipline of the for-loop fix). GNU's driver runs stupidly_hack_special_variables after every completed bind (subst.c:8169; for the for-loop caller execute_cmd.c:3093 and 3097-3100), so this one store-layer change covers element assignment and for/select binds over arrays alike. - declare's assign pass set a compound operand's ARRAY/ASSOC marks only after its funnel read, so the warning named the raw storage render instead of the projection, and an assoc bind without a "0" key warned where GNU stays silent. Align the marks with the bind result before the funnel reads it. - declare never ran GNU's per-variable stupidly_hack_special_variables (builtins/declare.def:1105), so attribute-only conversions of an existing scalar locale variable and element operands never fired at all, and compound operands missed their second fire (their assign-pass fire stands in for the pre-declaration assignment's hack, subst.c:8169). The assign pass now records its fires per operand (LocaleFunnelRecord) and the execute tail runs the owed hack after the attribute pass, when conversions (declare.def:953-962) are in final shape. Lane W-LOCALE, wave 2 pin-to-fix for the locale funnel array channels (issues 3066 and 3097).
…ework) A bare element assignment statement (LC_ALL[0]=v, indexed or assoc, including +=) dispatches to execute_array_element_assignment, never through apply_shell_assignment -- so the funnel notes the first commit placed in apply_nameref_array_element_assignment never fire for this shape. GNU's assignment driver runs stupidly_hack_special_variables after assign_array_element (subst.c:8169) and sv_locale (variables.c:6272) reads the NEW scalar projection (get_string_value, variables.c:2495). Add the same note_locale_assignment at this executor's three store convergences: the assoc fast-append arm, the assoc canonical arm, and the indexed tail all indexed arms converge on. One bind, one note.
caomengxuan666
marked this pull request as ready for review
November 10, 2026 12:11
This was referenced Nov 10, 2026
caomengxuan666
added a commit
that referenced
this pull request
Nov 10, 2026
…-funnel resolution Conflict resolution, 2 files / 3 blocks, all on the declare face; sole source master 504c6e8 (PR #3242, rubash#3066/#3097 LocaleFunnelRecord) landing after this branch's resolution base d4f7d94. The funnel semantics are re-landed in post-migration (Diag/prolog) form; neither side is taken wholesale. - declare/assign.rs: LocaleFunnelRecord struct and its doc kept verbatim from master; assign_declare_names keeps the migrated signature (diag/prolog, no <W: Write>/stderr) and gains the locale_funnel out-parameter. The two note() sites sit exactly on the assign pass's sv_locale fire points (variables.c:6272), and the #3097 mark-alignment (attribute bits settled before the funnel reads the projection, variables.c:2495) is preserved. - declare.rs call site: HEAD's gate kept. GNU builtins/declare.def:389-406: the pflag branch runs before all making-variables machinery, so under -p the assign stage is skipped outright and mark_unset_declarations stays literal true; master's !print-as-argument form would run assign under -p and resurrect the E1 defect (`declare -p dv=6` binding). The record is created before the gated call and passed in; under -p neither the assign pass nor the verdict loop (same !print block) runs. - declare.rs hack verdict: master's per-operand loop kept (GNU builtins/declare.def:1105 stupidly_hack_special_variables runs after every processed variable); its diagnostic is re-landed in migration form as bare_diag_line(diag, prolog, ...), the same rendering the two assign-phase fire sites already use, instead of master's writeln!(stderr, diagnostic_prefix ...). Refs #2707
caomengxuan666
added a commit
that referenced
this pull request
Nov 10, 2026
…2968) Stage-2 ④ Phase 4: the variable-attribute family (declare/typeset, local, readonly, export, unset, alias/unalias) migrates onto the Phase 0–3 infrastructure — one declaration-table row, the single BuiltinOpt parser, and the Diag handle. The assignment machinery now takes `&mut Diag` bound at the dispatch point, so a readonly diagnostic is written through the command's own fd 2 (redirect-aware) instead of an ambient stderr — this settles A3-R1 (#2707). Captain verification highlights: E1 option/attribute matrix 232 cells, SAME 189 → 230 with 41 flips all DIFF→SAME and zero regressions (the two remaining cells are filed as #2971); E3 differential matrix 3112 cases, SAME 2756 → 2801, exactly 45 flips all in-family --help cells, zero regressions; regression pins 18/18 (including seven cells added for the unset repair below); full lib 1188 passed / 0 failed / 4 ignored; RUSTFLAGS="-D warnings" clean; UTF-8 hygiene clean. One regression the migration itself introduced was caught in captain verification and fixed on this branch (ba25d2e): execute_unset kept pre-migration branches that opened a plain `2>file` target directly for the Diag, and the new trailing buffered-output route re-applied the redirects — the second, truncating open erased the readonly diagnostic, so `readonly uv=old; unset uv 2>f` lost it entirely (GNU and pre-migration master both deliver it to f). Unset now buffers both streams and lets the single ordered route apply the redirects once, like the rest of the family; a captain probe battery of 14 cells (unset file/append/dup/no-redirect/unopenable, readonly assignment and arithmetic faces, and one diagnostic cell per migrated family member) is byte-identical to GNU bash 5.3.20. Two later additions ride on this branch. The E4 follow-up removes three per-call overheads on the declare-family success path (stack-parsed BuiltinOpt spec, flag fast scan, lazy print_names snapshot); it lands on structural evidence under the captain's E4 ruling, with the residual (≲1.5%) booked as performance debt under #3232. Master meanwhile landed the locale-funnel work in pre-migration form (PR #3242); merging master into this branch re-lands that funnel semantics in migrated form — LocaleFunnelRecord rides the migrated assign_declare_names signature and the !print gate keeps the outer-gate shape (GNU declare.def:389-406 and declare.def:1105) — and the funnel regression pins pass unchanged (issue3066 8/8, issue3097 8/8, issue2707 18/18, the six #2997 residual stems all green, lib 1233 passed / 0 failed / 4 ignored on the merged head). Pre-existing divergences found on the way are filed for later and left untouched here. The tracking issues are #2970 (getopts OPTARG), #2971 (export/readonly -aA priority), #2972 (declare listing attribute filters), #2973 (declare listing rendering), #2974 (local -f/-F nameless) and #2975 (bare unalias exit code). 本 PR 删除了什么:变量属性族各 builtin 手写的选项解析与诊断前缀代码(由 BuiltinOpt + Diag 取代)、赋值机械的 `buffer_assignment_diagnostics` 缓冲机制(改为 Diag 直通)、unset 的迁移前直开重定向分支(双重应用重定向的回归源)。净行数以 PR 文件账为准(42 文件 +2214/−1289,含队长 fmt 提交、unset 专修提交、E4 三刀与 funnel 消解 merge)。 Refs #2707
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.
本 PR 删除了什么
无删除。本 PR 为纯增量修法:漏斗注记补到四个早退的存储臂、declare 赋值通道的漏斗记录结构与标记对齐、declare 执行尾的 GNU hack 环。唯一移除的是 declare 赋值主路径中位于警告之后的一处 compound ARRAY 标记块——其职责由警告之前的标记对齐取代(标记集合不变,仅时序提前)。
修法概要
漏斗(
src/locale.rs的locale_assignment_warning)本身不动;修的是三处「绑定已完成、漏斗却没被调用/读错投影」的机制面:src/executor/temporary_assignments.rs):元素赋值(assoc/indexed 两臂)、标量覆写数组臂、标量覆写 assoc 臂在通用尾注记之前return,绑定完成后从未记账。在各臂存储点补note_locale_assignment——一次绑定一次注记,记在执行存储层(与已关单的 for 循环口径同源)。此一处同时覆盖元素赋值、for/select 覆写数组、read 等全部经存储层的通道,for 调用方不另记账。assign_array_element/bind_variable后跑stupidly_hack_special_variables);variables.c:3128-3142(标量绑定落元素 0 / "0" 键);execute_cmd.c:3093、3097-3100(for 绑定后 hack);variables.c:6272sv_locale经 get_string_value(variables.c:2495)读新投影。src/builtins/declare/assign.rs):compound 操作数的 ARRAY/ASSOC 标记原在漏斗读取之后才置位,漏斗遂按原始存储串警告(\x1d([0]="...")/(([0]=...))),且无 "0" 键的 assoc 误报。现将标记对齐前移到漏斗读取之前(与属性遍最终形态一致),漏斗读到元素 0 / "0" 键投影;同时以LocaleFunnelRecord逐操作数记账本遍的 fire(标量/复合区分)。src/builtins/declare.rs):GNU declare.def:1105 在每个被处理变量后跑stupidly_hack_special_variables。在属性遍之后(转换形态已定型)按记账补跑:复合操作数欠一次(其赋值遍 fire 属声明前赋值 subst.c:8169)、无 fire 的操作数(纯属性转换、元素操作数)欠一次、普通标量绑定的赋值遍 fire 即 hack 本人不多跑。local与declare共用此路径(GNU 同为 declare_builtin);转换发生在 declare.def:953-962(赋值之前)。已知文件面重叠(合入排序提示)
src/builtins/declare.rs、declare/assign.rs、src/executor/temporary_assignments.rs等文件;本 PR 基于当前 master 尖端,合入时请按队列顺序处理可能的文本冲突。temporary_assignments.rs内插入 dynamic-assoc 臂,与本 PR 的四处注记 hunk 不相交。Refs #3066
Refs #3097