#648

fix(awk): count array elements in length

Openasafyishwants to merge intofrom

Fixes https://github.com/vercel-labs/just-bash/issues/647.

length(array) returned zero because the array name was converted to an empty scalar. Count array entries before scalar evaluation, using the existing alias resolver for function parameters. String and no-argument behavior stays unchanged. Parameter bindings distinguish scalar arguments from array aliases and restore the caller binding after a nested call; otherwise a scalar parameter can accidentally count a same-named global array. The saved-data replay exposed that regression, now covered here.

Nine focused cases cover split-created arrays, overwrites/deletes, nested parameter aliases, special keys, built-in arrays, and scalar lengths, and scalar parameters shadowing global/caller arrays. Native awk agrees with the expected outputs; the array cases fail before the fix.

Validation: 878 awk unit/spec/comparison tests pass (one existing skip), package typecheck and repository lint pass.

Activity

3
vercel[bot]11d ago

@asafyish is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.