Skip to content

fix(locale): funnel reads the scalar projection of array-bound locale vars (Refs #3065) - #3080

Merged
caomengxuan666 merged 5 commits into
masterfrom
fix/3065-locale-funnel-array-value
Nov 8, 2026
Merged

caomengxuan666 merged 5 commits into
masterfrom
fix/3065-locale-funnel-array-value

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Refs #3065

根因

共享 locale 漏斗 locale_assignment_warning(src/locale.rs)从存储映射里按原始字符串读 locale 家族变量的值。数组绑定的存储形态是复合串(\x1d([0]="C")),于是漏斗拿复合串去试 setlocale 并把它原样写进警告文本:LC_ALL=(C) 误报、LC_ALL=(bogus_XX) 的警告渲染成 (\x1d([0]="bogus_XX")) 且漏出 0x1D。

GNU 侧:sv_locale(variables.c:6272)经 get_string_value(variables.c:2495)→ get_variable_value(variables.c:2473)读绑定——索引数组投影到元素 0、assoc 投影到 "0" 键(缺失即 NULL)、其余即存储值本身;set_locale_var(locale.c:185)用该标量试 setlocale 并据此渲染警告。类别优先级读 get_locale_var(locale.c:343)同理。

修法(一处机制,全通道覆盖)

  • src/locale.rs:新增 stored_scalar_value——与标量读路径同一对投影原语(array_value_at/assoc_value_at),按 VarTable 的 array/assoc 属性投影。漏斗本体、get_locale_var、reset_locale_vars_mirror 的全部取值改走投影;漏斗签名由 &HashMap 改为 &VarTable。
  • 算术通道([bug] arithmetic assignment to a locale variable never warns on setlocale failure (((LC_ALL = 5)) silent) #3059 的绑定日志):记录元组加带绑定时刻 LC_ALL 的 array/assoc 标记,probe 表据此标记,使复合 LC_ALL 快照在漏斗里同样投影。

队长接管与范围拆分(2026-11-08)

车道在交付前死亡,本地链未推送且修复提交不编译(五参签名漏改一处调用点 + 一处私有模块路径)。队长接管:补完提交 a9fecde7(compound_exec.rs 的 C-for 面补两标记参数,与其它调用点同形;array_value_at 升 pub(crate) re-export),其后全部验证由队长在独立复核树重跑。

复核中三格同族异机制残余经 GNU 5.3.20 oracle 逐形亲验后拆出本 PR,另立 #3097(钉格随移、断言不变):元素赋值与 for 绑定通道对数组 locale 变量根本不触发漏斗(GNU 各响一次、rubash 静默);declare 通道的漏斗投影判据与 declare 标记集不同源,警告仍命名存储形(值面)。declare 的警告次数面仍归 #3066(declare.def:1105),本 PR 不动。

队长复核证据(全量日志 review-3065/verify.log)

本 PR 删除了什么

无产品删除。钉文件按上述拆分移出 3 格到 #3097(断言原文保留在该单与本 PR 的提交说明中);源码为漏斗投影改造 + 算术日志元组扩两布尔 + 一处可见性放宽,无文件/函数/行为删除。

Captain completion of the lane's cd90936, which did not compile:
the lane extended record_arith_locale_bind to five arguments (name,
value, lc_all, lc_all_array, lc_all_assoc) at the definition and two
call sites but missed the C-for fastpath site in compound_exec.rs,
which still passed three; and locale.rs read the array projection
through the private module path executor::arrays::array_value_at.
Pass the LC_ALL array/assoc attrs at the missed site exactly as the
other call sites do, and re-export array_value_at at pub(crate) from
executor (mirroring assoc_value_at) for the funnel's scalar
projection. No semantic change beyond completing the recorded
design.
Captain scope split at PR #3080 review. The funnel projection fix
verifies on the nine cells pinned here, but three drafted cells
exposed gaps with different mechanisms, oracle-verified against GNU
bash 5.3.20 on this tree: the element-assign channel and the for-bind
channel never fire the funnel for an array locale variable (GNU
warns once, rubash is silent), and the declare channel's funnel call
projects via attr_of while declare keeps array-ness in the mark
sets, so declare warnings still name the storage render. Those
cells move to #3097 with their assertions intact; the declare fire
COUNT remains #3066 as before. The module header records the split.
@caomengxuan666
caomengxuan666 force-pushed the fix/3065-locale-funnel-array-value branch from 7b3c77d to 5d71e6d Compare November 8, 2026 07:15
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 8, 2026 07:15
@caomengxuan666
caomengxuan666 merged commit 1c132f6 into master Nov 8, 2026
11 checks passed
caomengxuan666 added a commit that referenced this pull request Nov 9, 2026
test: wave-2 pins W2d (Refs #3066, #3084, #3097)

第二波「钉先行」车道 W2d 的回归钉(基底 master `f17644d7`)。三单的修法面均被在飞 PR #2968 的文件表占住(declare/assign.rs、compound_exec.rs、temporary_assignments.rs),本 PR 只落钉 + 根因/修法设计(见车道 REPORT),门开后修法车道按钉施工。

Refs #3066 — declare 通道 locale 漏斗触发次数:`declare -a`/`declare -A` 转换既有标量、复合绑定、`local` 复合绑定在 GNU 均双响(declare.def:1105 的 per-variable hack),rubash 只响一次。钉文件 `tests/issue3066_declare_conversion_locale_funnel.rs`(含 fresh/有效值/标量 declare 对照与链路读回)。

Refs #3084 — DQ 反斜杠 case 主词:`case "${v=a\ b}"` 主词在 GNU 保留反斜杠(nomatch),rubash 丢失(match)。钉文件 `tests/issue3084_case_word_dq_backslash.rs`。

Refs #3097 — locale 漏斗三残余:元素赋值与 for/标量覆数组绑定不喂漏斗(存储臂早退跳过 note);declare 通道漏斗投影判据(attr_of)与标量读路径(标记集)不同源,警告命名原始存储形。钉文件 `tests/issue3097_locale_funnel_array_channels.rs`(含 #3080 移出的 3 格原文断言)。

队长复核:A0 纯钉审计、C 腿 GNU 5.3.20 抽查(20 探针全吻合)、D 卫生(rustfmt/marker-lint 均净)、E CI 10 success + 1 skipped 均已落;B 腿 fail-first 实测:基底 5 绿/17 红(#3066 2 绿/6 红、#3084 3 绿/3 红、#3097 0 绿/8 红),头树逐 fn 完全相同(详见复核记录)。

## 本 PR 删除了什么

无(纯测试新增)。净行数:+720 行(3 个新钉文件:`tests/issue3066_declare_conversion_locale_funnel.rs` +263、`tests/issue3084_case_word_dq_backslash.rs` +150、`tests/issue3097_locale_funnel_array_channels.rs` +307;删除 0 行)。

注意:master 已推进到 `a432632d`(#3098 合入),合入前须 update-branch。
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.

1 participant