Repository navigation
arithmetic: evaluation-order event log for diag/warning emission - #3244
Merged
Merged
Conversation
Non-fatal arithmetic diagnostics, locale bind warnings and the readonly line were emitted from three separate boundary stages, so their stderr interleaving could never match GNU evaluation order (diag -> warning -> diag was impossible). Route all three classes through one evaluation-order event log, recorded at the production points (GNU expr.c:331/352 bind hook, variables.c:3403, arrayfunc.c:402) and drained once, in order, at each evaluation boundary. Refs #3078 UNVERIFIED-BY-CAPTAIN
report_arithmetic_readonly_error lost its only call sites when this branch migrated the three ordered boundaries to the evaluation-order drain; the drain's Readonly arm carries the same guards (same-name marker removal, readonly/expansion latches, print iff first error), so the fallback is unreachable dead code and the final head fails RUSTFLAGS=-D warnings on it (never used). Delete the function and update the two comments that named it (shell/state.rs field doc, issue2641 pin header; the drain arm keeps the raw-eprintln print that pin describes). Semantics-neutral: no live path changes.
caomengxuan666
marked this pull request as ready for review
November 10, 2026 14:36
# Conflicts: # src/executor/arithmetic/mod.rs
caomengxuan666
added a commit
that referenced
this pull request
Nov 10, 2026
…nt-log resolution Master (PR #3244) folded the standalone arithmetic readonly reporter into the ArithEvalEvent drain; its Readonly arm emitted through a raw eprintln!, the pre-migration routing A3-R1 had already moved off. This merge accepts the drain structure and the reporter's deletion, and re-lands the A3-R1 fd-2-bound routing (arith_diag = write_diagnostic_fd2; GNU error.c:453 err_readonly, report_error family) inside the drain's Readonly arm. Marker-by-name consumption, the reporter latches and the drain's evaluation order stay master's, verbatim. Refs #2707
caomengxuan666
added a commit
that referenced
this pull request
Nov 10, 2026
…3288) 算术 nameref 报错入 ArithEvalEvent 单日志(rubash #3246) 空 cell nameref 在算术里被赋非名字形值时,GNU 在绑定点即时发 `` `1': not a valid identifier ``。本 PR 让该报错进入求值序事件日志(沿 #3244 的 ArithEvalEvent 单日志机制),取代边界后补发的单槽 marker 报告器: - `src/executor/arithmetic/value.rs`:空 cell 非法值分支改调 `record_diag(ArithEvalDiag::InvalidIdentifier(value))`(绑定点入日志,一绑定一事件)。 - `src/executor/arithmetic_aliases.rs`:删除 `report_arithmetic_nameref_error` 整体及 `((` / `let` 两处调用点;状态改由表达式值决定;`let` 循环续评后操作数。 - `src/executor/arithmetic/mod.rs`:`print_arith_diag` 三臂由裸 `eprintln!` 改走 fd-2 绑定通道 `self.arith_diag(...)`(与 #2968 合入的 Readonly 臂同路由,三臂全走 `arith_diag`);`eval_arithmetic_expansion_value` 内删报告器调用。 - `src/executor/expand_braced_indices.rs`:`apply_pending_subscript_writes` 开头加 `drain_arith_eval_events(None)`(无条件执行;下标求值经 `&self` deferred 路径只评一次且被 memo 化,mut 入口永不重评,故事件无排口;该落点是同次求值的写落地边界,标签 None)。 - `src/executor/markers.rs`:删除 `__RUBASH_ARITH_NAMEREF_ERROR` 注册行。 - `tests/issue3246_arith_nameref_eval_order.rs`:新钉 18 格(五形 + 裸状态、双 nameref、let 状态、展开值、下标两形、cond 操作数、fd2 两形)。 ## 本 PR 删除了什么 - `report_arithmetic_nameref_error` 函数整体(`src/executor/arithmetic_aliases.rs`)及 `((` / `let` 两处调用点。 - `__RUBASH_ARITH_NAMEREF_ERROR` 单槽 marker 注册行(`src/executor/markers.rs`)。 - 空 cell 非法值分支的 marker 插入(`src/executor/arithmetic/value.rs`),改为事件日志记录。 - 上述删除均由 ArithEvalEvent 单日志机制承接,无行为真空;全树对 marker 字面与报告器名零残留。 ## 队长复核(`~/workspace/review-3288/CAPTAIN-VERIFY.md`) - 头钉 18/18;基底 fail-first 2 过 / 16 红(逐名核对一致);邻茎 issue3078 19/19 双边;lib 双边 1233/0/4 名集 ∅=∅(双树先建 `--bin rubash`——基底亦全绿,车道账面「基底 1232/1/4 唯一红 issue2875」为未建 bin 的环境产物,已推翻)。 - 五腿 rc=0:`RUSTFLAGS="-D warnings"`(lib+bins,touch + `-v` 亲证 rustc 真载 flag)、fmt 全树、marker-lint(117 注册常量、267 allowlisted sites)、UTF-8 边界卫生、`cargo check --tests`(32 条警告全在既存他茎测试文件,本 PR 文件零警告)。 - GNU oracle:车道 7 份探针 6 份全同,唯 gnu-extra.sh stderr 差 2 处(sub1 子串偏移标签 + sub5 一对);复核员 6 份 adversarial 探针三方对照(GNU/基底/头树):S1/S2/S5 与 GNU 逐字节一致,S4/S6/S7 仅标签一格有差(基底五形更差——缺行/错序/静默/状态错;头树全部修净缺失与错序,只剩标签,见残差)。 - CI:10 pass + 1 skipping,零红;merge-tree 对当前 master 零冲突。 - 三点裁断:(a) apply 点 drain 四调用面确无入口窗口内调用;(b) #3287 与本 PR 合入脱钩(标志泄漏机制基底与头树逐行相同,本 PR 未制造);(c) `print_arith_diag` 合并形态干净。 - 残差(均不阻塞,均须另立案):① 子串偏移标签 `${v:ref=1:2}`(GNU 带 `v: ` 标签、头树无;归宿 subst.c 报告路径车道);② 算术文本内展开期诊断标签(S4 嵌套 `$(( ))`、S6/S7 下标形:头树打 `((:` 标签、GNU 无标签;既存分歧收窄后的残余,修法须另案调查两生产点)。 Refs #3246
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 #3078
UNVERIFIED-BY-CAPTAIN
What
Inside one arithmetic expression, GNU bash 5.3 emits every non-fatal stderr line synchronously at its point in evaluation order: a locale bind warning fires at the bind (expr.c:331
expr_bind_variable-> expr.c:352stupidly_hack_special_variables-> variables.c:6272sv_locale-> locale.c:185set_locale_var->internal_warning), a non-fatal diagnostic fires where the bind/subscript helper produces it (variables.c:3403sh_invalidid; arrayfunc.c:402err_badarraysub), and a readonly bind failure fires at its bind point (expr.c:350). rubash kept three separate boundary stages — the readonly reporter, the diagnostic mailbox, and the locale-bind journal drained inside the write sync — so interleavings such as diag -> warning -> diag could never be reproduced; the merged pins recorded 8 such cells red.This change routes all three classes through ONE evaluation-order event log (
ArithEvalEvent::{Diag, LocaleBind, Readonly}in a single thread-local), appended at the production points and drained once, in order, at each evaluation boundary (command / subscript / expansion entries, plus the[[ ]]operand flush). Producers inside nested evaluations append directly, so the log is the global evaluation order by construction. The locale funnel and the diag rendering (including carrier de-coding, rubash#2341) are reused unchanged inside the drain; the sync fallback still extracts only locale binds for boundaries that do not drain. The whole-value$((...))fast-assignment route now uses an unlabeled entry variant so an expansion-context InvalidIdentifier line no longer gains the((:label.本 PR 删除了什么
ARITH_LOCALE_BINDSandARITH_EVAL_DIAGSthread-locals and their take/clear helpers (take_arith_eval_diags,clear_arith_locale_binds) — replaced by the singleARITH_EVAL_EVENTSlog.diags: Vec<ArithEvalDiag>field onConditionalArithParserand theadopt_diagsmerge step in value.rs (nested frames record directly into the shared log).report_arithmetic_readonly_error()call at the three ordered boundaries — it remains only as a fallback for non-draining boundaries and stays silent while a matching Readonly event is pending.Lane-local verification (captain re-verifies)
tests/issue3078_arith_diag_warning_order.rs: 19 passed / 0 failed (base fail-first via batch Track GNU Bash upstream test progress in CI #3 leg B4: 11 passed / 8 failed; all 8 reds turn green, the 11 greens hold).1206 passed / 0 failed / 4 ignored(failure name set empty); base tree at 567e4bb1205 passed / 1 failedwith the single base-only redapi::consumer_tests::issue2875_input_procsub_child_runs_as_rubash_shell, which is green at head — head-only failure set is empty.RUSTFLAGS="-D warnings"cargo check (lib+bins): rc=0.cargo fmt --check: rc=0. Marker-lintscripts/check-marker-literals.py: OK.~/workspace/fix-3078/REPORT.mdand leg logs in~/workspace/fix-3078/legs/(not in repo).返工订正(队长复核后,新头 4ae83b5)
report_arithmetic_readonly_error已整段删除(不留兜底)——队长核基底确认其调用点恰只有被本 PR 迁移的三处边界,头树零调用点即 dead code;drain 的 Readonly 臂已含同款守卫,删除语义中性。src/shell/state.rs与 issue2641 钉头注释中对该函数名的引用已同步改述,全仓该标识符归零。legs/warnings.log)为终提交前的中间树产物(调用点尚在时取得),对头693df928不成立(队长亲跑 rc=101)。返工头4ae83b54已复跑三腿:-D warningsrc=0(零警告行)、头钉 19/19、lib 头1206 passed / 0 failed / 4 ignored(失败名集为空);日志~/workspace/fix-3078/legs/(warnings-rework.log/pin-head-rework.log/lib-head-rework.log),全账见 REPORT §7。