Skip to content

[bug] declare -i x; x=(1+2) stays a SCALAR in rubash — GNU 5.3 converts to an integer ARRAY declare -ai x=([0]="3") #246

Closed

Description

@caomengxuan666

Found by: the #214 verification matrix (corpus2 re-run lane). Pre-existing divergence, byte-reproduced while writing the compound-append class fix; NOT introduced by the #214 change (that change only routes += compound lists).

Reproducer (LF script file, identical bytes both shells):

unset t
declare -i t
t=(2*3)
declare -p t
  • GNU Bash 5.3.0 (WSL /usr/local/bin/bash): declare -ai t=([0]="6") — an integer ARRAY whose single element is the evaluated expression.
  • rubash (wt4/corpusfix): declare -i t="6" — a scalar; the value is right but the type is wrong (and ${t[0]} / t[1]=x semantics then diverge).

GNU C source owner: arrayfunc.c:454 find_or_make_array_variable — a compound ( ... ) assignment on a non-array variable CONVERTS it (convert_var_to_array, arrayfunc.c:498) unconditionally; there is no "single arithmetic expression stays scalar" carve-out in 5.3. The multi-element form already behaves correctly in rubash (declare -i r; r=(1+2 3) → declare -ai r=([0]="3" [1]="3") matches GNU); only the single-expression case diverges.

Rubash owner: src/executor/temporary_assignments.rs — the integer_compound_assignment_is_scalar branch ("Bash keeps typeset -i x; x=(1+2) scalar") is stale against 5.3 (may have described 5.2; re-verify against scripts/true-baseline-521.sh before removing — if 5.2.21 also converts, the carve-out is simply wrong; if 5.2.21 keeps scalar, the branch needs a compatibility-level gate).

Classification: rubash-caused (WSL GNU 5.3.0 oracle). Artifacts: target/issue-suites/results/corpus2/probe/p214-int3.sh (GNU vs rubash outputs captured in the lane log), p214-int2.sh for the multi-element contrast.

Activity

  1. caomengxuan666 commented on Sep 27, 2026

    @caomengxuan666
    MemberAuthor

    已修复并合入 master(commit b20fb6a7,lane wt5/ble;GNU 引用与矩阵验证见提交:#244 词中 {} 不再是分隔符(syntax.h:29-30 两表均无)+函数名取任意 WORD;#245 算术 ((...<<=...)) 不再误判 heredoc(parse.y:3727 parse_dparen 先于重定向分支)——ble.sh source 终止且 rc=1 与 GNU 一致;#246 arrayfunc.c:454/498 无条件转数组(5.3.0 与 5.2.21 同行为)。ble.sh -n 推进到 28570 的新阻塞已开 #255。感谢报告!

  2. added
    bug
    area:expansion
    on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:expansionbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions