Skip to content

子串偏移展开的诊断丢标签:${v:ref=1:2} 应带 v: 标签(GNU 有、我方无) #3296

Closed

Description

@caomengxuan666

Summary

A substring-offset expansion through a nameref carries no label on its diagnostic where GNU prefixes the variable name: ${v:ref=1:2} — GNU emits the diagnostic with a v: label, rubash emits it unlabeled. Value and exit status are identical on both sides; only the label is missing.

Evidence (captain review of PR #3288, box, GNU bash 5.3.20 oracle)

Fix direction

Carry the label through the subst.c reporting path for this expansion form (the diagnostic's label slot is populated for the other nameref diagnostics; this one drops it). Destination: the subst.c reporting-path lane.

Activity

  1. added this to the 1.5.1 milestone on Nov 10, 2026
  2. added
    bug
    gnu-baseline
    P3-low
    area:expansion
    on Nov 10, 2026
  3. caomengxuan666 commented on Nov 11, 2026

    @caomengxuan666
    MemberAuthor

    按用户 2026-11-11 令,队长未完工的 rubash 队列整体移交 Uarz,本单 assignee 改为 Uarz。

    规矩见置顶单 #3341:assignee 即认领;先对照 GNU bash 5.3 源码定语义(引 file:line)再修、按机制修不打地鼠;每个修复带仓内回归钉并给出 fail-first 证据;第一笔提交即开 draft PR;不自合、不自关;正文 Fixes/Refs 口径与同句误关单纪律照 #3341。开工前先查本单是否已有 open PR 覆盖,有则先审 PR、不另起实现。

  4. caomengxuan666 commented on Nov 14, 2026

    @caomengxuan666
    MemberAuthor

    车道 L03 复核(未开工改码,原因见末段)。

    复现(origin/master 8b48c16,GNU 5.3.20 脚本文件双跑)

    形 GNU rubash
    declare -n ref; v=abcdef; echo "${v:ref=1:2}" v: \1': not a valid identifier` `1': not a valid identifier
    echo "${v:1:ref=1}" / ${v:(ref=1):2} / x=${v:ref=1:2} / 函数内 同上带 v: 无标签
    v=abcdef; echo "${v:a[]=1:2}" v: `a[]': not a valid identifier 无标签
    a=(a b c); echo "${a[@]:ref=1}" a[@]: `1': ...(一次) 无标签,且打印两次、行号错成下一行
    echo "${@:ref=1}" @: `1': ...(一次) 无标签,三次,行号错
    echo "${v:$(( ref=1 )):2}" 无标签 无标签(SAME)
    b=(1 2); echo "${v:b[ref=1]:2}" 无标签 无标签(SAME)

    GNU 依据

    • subst.c:9061-9075 parameter_brace_substring:this_command_name = varname 包住 verify_substring_values(subst.c:8395,内含 expand_arith_string + evalexp)。
    • 诊断标签是产生时刻的 this_command_name:expr.c:1529 evalerror、variables.c sh_invalidid(builtin_error 前缀)。
    • 内层清空:subst.c:10874 $(( 臂置 NULL;arrayfunc.c:1374 array_expand_index 置 NULL ——所以 $(( ref=1 )) 与 b[ref=1] 两格 GNU 无标签。

    为何本车道不动手

    本单与 #3295 是同一机制:rubash 的算术诊断事件(ARITH_EVAL_EVENTS)在 drain 时才取 entry 标签,而 GNU 取的是产生时刻的 this_command_name。同一机制的另一面在 master 上也可见:declare -n ref; b=(1 2); (( b[ref=1] )) GNU 无标签(arrayfunc.c:1374),rubash 报 ((: 1': ...;let 'b[ref=1]'rubash 报let: ...。按机制修应是"事件在产生点记下当时的 this_command_name 作用域(substring=varname,$((/下标帧=NULL)"——这正是 #3295 队长车道(2026-11-13 开工,分支 fix/3295-arith-diag-entry-label)在做的事。为免同机制两处并修冲突,建议并入 #3295 的修法一起收;${a[@]:...}/${@:...}` 的重复打印与行号漂移是另一面(&self 预扫描与真展开各求值一次、事件延迟到下一边界 drain),修 #3295/#3296 时一并对账。若队长希望本车道单独接 #3296,请示下。

  5. caomengxuan666 commented on Nov 18, 2026

    @caomengxuan666
    MemberAuthor

    队长车道临时接手(Uarz 休息期间):开始修 #3296。先重验钉子在现尖 f983851 上的 fail-first(#3871 已合入,标签槽机制已在尖上,余下为扫描清空与 &self 认领 drain 两面),再按 REPORT §3 动手;修法提交即开 draft PR,队长复核后合入。

  6. caomengxuan666 commented on Nov 19, 2026

    @caomengxuan666
    MemberAuthor

    Fixed by PR #3928 (merged 5eed057). 队长复核:自带钉 14/14 绿;头 CI census 79(新增 2 格为 issue1902/dead_coproc 已知抖动族,修面不可达);goldens 仅基线二名;其余腿全绿;服务器腿钉 14/14、lib 与 base 逐名对齐、-D warnings rc=0。§2.3 写入丢失残差已证伪(尖与 base 五形态皆 i=1),不另立案。Closing as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P3-lowarea:expansionbuggnu-baseline

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions