Skip to content

fix(declare): render FUNCNAME listings from the live call stack (Refs #2770) - #3466

Merged
caomengxuan666 merged 2 commits into
masterfrom
fix/2770-funcname-listing-view
Nov 13, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
fix/2770-funcname-listing-view

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

根因

FUNCNAME 在 declare/set 各类 listing 里没有 live view:PR #2766 把动态变量的 listing 改为 registry 驱动后,FUNCNAME 的 listing 仍渲染 init mirror——一个 birth snapshot("" 函数入口,从不刷新),而不是实时调用栈;且 #183 的 seed hack 会在 unset 后凭空造出一个 cell。

GNU 锚点(vendored bash 5.3)

  • variables.c:1835-1839 init_funcname_var:INIT_DYNAMIC_ARRAY_VAR ("FUNCNAME", get_funcname, null_array_assign) + att_invisible|att_noassign。
  • variables.c:1812-1824 make_funcname_visible:函数入口清 att_invisible,返回时重设。
  • variables.c:1066-1073 print_var_list:跳过 att_invisible cell——depth 0 的 bare declare/set 无行,可见后渲染 live stack。
  • builtins/setattr.def:510-511 show_var_attributes:invisible array 印 bare 名(depth 0 为 declare -a FUNCNAME),可见后带元素。
  • variables.c:3788 unbind_variable:unset 后 cell 在本 shell 生命周期内消失,declare -p FUNCNAME 报 not found。

改动

  • src/executor/dynamic_arrays.rs:FUNCNAME 加入 array declaration class、dynamic cell view、set-view supply(仅非空栈)、以及从 composed stack 渲染的专用 declaration view。
  • src/executor/declare_local.rs:named-print seed 永不 seed lifetime-unset 的 cell;FUNCNAME 加入 VISIBLE listing-refresh 类(与 GROUPS/BASH_SOURCE/BASH_LINENO 同列)。
  • tests/issue2770_funcname_listing_regressions.rs(新 stem,3 tests):顶层 named/listing/filter 形、函数内 live stack(含嵌套)、unset 后 view 消失;期望与 GNU bash 5.3 oracle 逐字节一致。
  • .github/workflows/ci.yml:新 stem 的 named nextest 步(该 stem 在其他 CI lane 之外,rubash#3430)。

本 PR 删除了什么

无产品代码删除。仅重组:FUNCNAME 的 listing 渲染从 stale env mirror 改为 live provider view;declare_local.rs 的 seed 条件收窄(unset 后不再造 cell)。

验证(UNVERIFIED-BY-CAPTAIN)

  • Box:新 stem head 3/3;base top-up fail-first 1 过 / 2 败(函数内 listing 与 unset 两格,正是本修所补)。
  • 待补:全量 lib 双边、RUSTFLAGS="-D warnings" check、GNU oracle 三方、相邻 issue2700 族 stem。

Refs #2770

…2770)

GNU ground: FUNCNAME is a dynamic array cell (variables.c:1835-1839
init_funcname_var: INIT_DYNAMIC_ARRAY_VAR, att_invisible|att_noassign);
make_funcname_visible (variables.c:1812-1824) clears att_invisible at
function entry, and print_var_list (variables.c:1066-1073) skips
invisible cells. Rubash rendered listings from the init mirror (a
birth snapshot function entry never refreshes) and the #183 seed hack
fabricated a cell after unset.

- dynamic_arrays.rs: FUNCNAME joins the array declaration class, the
  dynamic cell view, the set-view supply (non-empty stacks only), and a
  dedicated declaration view rendering the composed stack.
- declare_local.rs: the named-print seed never seeds a lifetime-unset
  cell; FUNCNAME joins the VISIBLE listing-refresh class with
  GROUPS/BASH_SOURCE/BASH_LINENO.
- tests: new stem issue2770_funcname_listing_regressions (3 tests:
  top-level named/listing/filter forms, in-function live stack incl.
  nested, unset removes the view), byte-verified against GNU bash 5.3.
- ci.yml: named nextest step for the new stem (outside every CI lane
  otherwise, rubash#3430).

UNVERIFIED-BY-CAPTAIN
@caomengxuan666

Copy link
Copy Markdown
Member Author

Captain review — PASS ✅

Reviewed head 4d041e9d against merge-base e50cea96 (git-verified; live master tip 3745712f). Full dossier: review-3466/CAPTAIN-VERIFY.md. The fix renders FUNCNAME listings from the live call-stack provider view (the #2700 registry direction) instead of the stale init mirror, and stops the named-print seed from fabricating a cell after unset. Mechanism-shaped, GNU-anchored, no per-form special cases.

GNU ground — re-verified in vendored bash 5.3, not taken on citation: variables.c:1835-1839 INIT_DYNAMIC_ARRAY_VAR + att_invisible|att_noassign; variables.c:1812-1824 make_funcname_visible; variables.c:1066-1073 print_var_list skips invisible cells; builtins/setattr.def:510-511 invisible array prints as bare name; variables.c:3788 unbind_variable.

Captain's own legs (X299-2607 + box + local):

  • Pin bilateral: head 3/3 by name; base + committed stem 1 pass / 2 fail — the failures are exactly ..._inside_a_function and ..._unset_removes_the_listing_view, the defect pair this PR removes (--bin rubash built first on both trees).
  • GNU oracle three-way (script-file probes): probe2770c byte-identical to GNU including diagnostics; probe2770 differs by exactly one 20-line hunk — GNU's bare declare prints function definitions, head omits them (pre-existing on base, out of variables: FUNCNAME has no listing view in declare/set output (split from #2700) #2770 scope; will be filed separately). Every FUNCNAME line matches GNU in every form.
  • Lib bilateral (Windows): head 1337/13/4, base 1338/12/4; the differing names sit only in the pathmatrix/drop-restore/locale families and flip in both directions — all 11 re-run individually on both trees pass 22/22, so the diff is adjudicated environment flake, no regression. Adjacent stems: issue2702 7/7 both sides; issue2700/2972/2973 identical results (same names) on head and base.
  • RUSTFLAGS="-D warnings" check rc=0 with proof of non-idleness (52 flagged rustc invocations, rubash lib recompiled under the flag, 0 errors); marker-lint rc=0, utf8-boundary hygiene rc=0, cargo fmt --check rc=0.

CI adjudication: final-head CI's three red jobs are all the issue2875_input_procsub_child_runs_as_rubash_shell cell (attempt 1's linux red was its issue2859 sibling) — the #3292 child-exe-resolution family. With --bin rubash built first, that cell passes in both head and base lib runs on X299, and master tip 3745712f's own CI fails the same three jobs. Not a regression from this PR. The new stem never executed in this PR's CI (the lib step died before the named step); its execution evidence is the captain's runs above, and after #3436 the census will run it on the merged head.

Intersection: only .github/workflows/ci.yml vs the master interval (#3436), hunks non-overlapping; no symbol deletions.

Two citation nits (non-blocking, no rework requested): the new comment/pin cite variables.c:3839 for unbind (function is at :3788), and the pin header cites builtins/declare.def:555-570 for show_localname_attributes (definition is at builtins/setattr.def:555).

Merge round: ready + update-branch, confirm the merged head's census step runs the issue2770 stem green and no new CI failure names appear, squash with this PR's body verbatim. #2770 stays open (Refs-only) — closed manually after merge.

@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 13, 2026 01:42
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