Repository navigation
arith: nameref bind failure enters the evaluation-order event log - #3288
Merged
Merged
Conversation
Empty-cell nameref adoption of an invalid value (GNU variables.c:3076-3079, sh_invalidid at the bind point; expr.c:331-354, no longjmp on the NULL bind) now records ArithEvalDiag::InvalidIdentifier in the ArithEvalEvent log instead of a single-slot env marker consumed after the boundary. The diagnostic drains in evaluation order with the locale warnings, the status is the expression value, later let operands still evaluate, and the fast-assignment route no longer leaks a stale diagnostic into the next command. The drain's Diag arm and the deferred subscript-write apply point emit through the fd-2-bound channel (GNU error.c writes diagnostics to fd 2 as currently bound).
This was referenced Nov 10, 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.
摘要
空 cell nameref 在算术里被赋非名字形值时,GNU 在绑定点即时发
`1': not a valid identifier(variables.c:3076-3079的sh_invalidid,expr.c:331-354的expr_bind_variable在 NULL 绑定上不 longjmp,求值继续、赋值取 RHS 值)。本 PR 让该报错进入求值序事件日志(沿 rubash #3244 的ArithEvalEvent单日志机制),取代边界后补发的单槽 marker 报告器。修法后五形行为与 GNU 一致:
(( ref=1, LC_ALL=5 )):diag → 警告,rc=0(原序反、rc=1);(( LC_ALL=5, ref=1 )):警告 → diag,rc=0(原序偶合、rc=1);x=$(( ref=1, LC_ALL=5 )):diag → 警告,x=5(原 diag 整条缺失);x=$(( ref=1 ))后接(( 1 )):diag 当场发,不再泄漏到下一条命令(原当场缺失、下一条命令补发陈旧 diag 并 rc=1);let "ref=1" "LC_ALL=5":diag → 警告,两操作数都求值,rc=0(原仅 diag、第二操作数未求值、rc=1)。另两点:
${a[ref=1]}、[[ ${a[ref=1]} = y ]])经&selfdeferred 路径只评一次且无入口 drain,事件在apply_pending_subscript_writes落点以无标签排出(GNUarrayfunc.c:1374-1378,this_command_name为 NULL);两次求值各打印一行,无去重。arith_diag),(( ref=1 )) 2>file与(( a[]=1 )) 2>file的诊断入文件、外层 stderr 为空(GNUerror.c写 fd 2 as bound;Readonly 臂同路由由 rubash Stage-2 ④ Phase 4: variable-attribute family onto Diag (Refs #2707) #2968 的合入带入)。本 PR 删除了什么
report_arithmetic_nameref_error函数整体(src/executor/arithmetic_aliases.rs),及((与let两处调用点(两处强制 status 1 的逻辑随之移除,状态改由表达式值决定);__RUBASH_ARITH_NAMEREF_ERROR单槽 marker:src/executor/arithmetic/value.rs生产点的插入、src/executor/markers.rs的注册行;src/executor/arithmetic/mod.rs里eval_arithmetic_expansion_value对该报告器的调用(drain 已覆盖)。验证(头树
f5b903ee,基底d9555905)tests/issue3246_arith_nameref_eval_order.rs:头树 18/18,基底 fail-first 2 过 16 红(仅 valid-cell 控制与 fatal-expansion 守卫在基底上过);issue3078_arith_diag_warning_order:19/19;issue2875_input_procsub_child_runs_as_rubash_shell,头树同跑过);无头树引入失败;RUSTFLAGS="-D warnings"检查 lib+bins rc=0;cargo fmt --check全树 rc=0;scripts/check-marker-literals.pyrc=0;scripts/check-utf8-boundary-hygiene.shrc=0;cargo check --testsrc=0(32 条警告全在既存他茎测试文件,本 PR 文件零警告);probes/,头二进制 vs GNU 5.3.20):7 份中 6 份 stdout/stderr/rc 全同;仅gnu-extra.shstderr 差 2 行,见下。已知残差(不属本 PR 范围,另立单跟踪)
${v:ref=1:2}:GNU 打印v: \1': ...(参数名标签,subst.c 侧另一报告路径),头树打印无标签行。行为(值bc`、rc=0)一致,仅标签差一格;钉文件未收该形。x=$(( ref=1, 1/0 ))之后,其后(( ))命令的求值被陈旧的arithmetic_fatal_error标志跳过、evalerror 报告被陈旧的arithmetic_expansion_error闩挡住(基底同病,基底曾靠陈旧 marker 泄漏偶然遮住一行)。已另立 rubash 致命快赋值后算术致命/展开错误标志跨命令泄漏:后续 (( )) 求值被跳过、诊断全静默 #3287,附金丝雀证据与修法面分析;本 PR 不动标志生命周期。Refs #3246