Skip to content

fix(arith): assign to array elements in ((...)), let and $((...)) - #2558

Merged
chaliy merged 1 commit into
mainfrom
claude/fidelity-array-arith
Oct 7, 2026
Merged

chaliy merged 1 commit into
mainfrom
claude/fidelity-array-arith

Conversation

@chaliy

@chaliy chaliy commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Requested by Михайло · project thread

What changed

Arithmetic can assign to array elements: ((a[i]++)), ((c[$k]+=3)), ((a[2]=5)), ((--a[0])), let a[1]++, $((c[x]--)). Indexed subscripts are evaluated arithmetically (negative indexes count from the end). Associative keys are literal, with $name/${name} expanded and quotes dropped (c["x y"], c[k$i]).

Why

Counting with ((count[$word]++)) is a very common agent idiom. Gap telemetry showed it silently produced empty or stale values.

Before

$ bashkit -c 'a=(1 2); ((a[1]++)); declare -A c; ((c[x]++)); ((b[3]=7)); echo "${a[1]} ${c[x]}"; declare -p b'
2
bash: declare: b: not found

After

3 1
declare -a b=([3]="7")

arith-array-lvalue.test.sh (14 cases) matches real bash 5.2 on every case.

Risk

Low. Writes go through the same budgeted array writers as ${a[i]:=v}; new test tm_dos_060_arithmetic_array_writes_respect_budget checks max_array_entries still caps them. ((...)) now drops lexer quote markers from words (bash removes quotes there too).

Checklist

  • Failing spec first, verified against bash
  • cargo test -p bashkit --lib --tests, clippy, fmt
  • knowledge/log.md

https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA


Generated by Claude Code

@chaliy chaliy self-assigned this Oct 7, 2026
@chaliy
chaliy force-pushed the claude/fidelity-array-arith branch from bbd9f62 to d083b51 Compare October 7, 2026 11:53
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit df75976 Commit Preview URL

Branch Preview URL
Oct 07 2026, 12:09 PM

((a[i]++)), ((c[$k]+=n)), ((a[2]=5)), let a[1]++ now update the
element instead of losing the write. Indexed subscripts are arithmetic
(negative allowed); associative keys are literal with $name expanded
and quotes dropped. Writes stay on the budgeted array writers.

Claude-Session: https://claude.ai/code/session_019aFikmptPc91Fj4N2iDXQA
@chaliy
chaliy force-pushed the claude/fidelity-array-arith branch from d083b51 to df75976 Compare October 7, 2026 12:09
@chaliy
chaliy merged commit 878545e into main Oct 7, 2026
44 checks passed
@chaliy
chaliy deleted the claude/fidelity-array-arith branch October 7, 2026 12:29
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