Repository navigation
fix(executor): reject [@]/[*] in compound assignment before arith eval (#636) - #656
Merged
Merged
Conversation
#636) a+=( [@]=q ) aborted on both shells, but GNU says [@]=q: cannot assign to non-numeric index while rubash said @: arithmetic syntax error. GNU rejects ALL_ELEMENT_SUB before arithmetic eval, naming the whole element word (arrayfunc.c:786-792); rubash fell through to evalexp. Two guards (preexpanded + declare compound arms) match the resolved subscript exactly ([@], ['@'], [$k], both =/+= tails) before eval_indexed_subscript_expression, emitting <word>: cannot assign to non-numeric index via diagnostic_prefix. No abort: like the []= arm, Err carries GNU's break (partial store kept, eval contains it). Assoc @ never reaches the guards (assoc arms return first); [ @ ] stays arithmetic; single a[@]=v untouched (different GNU owner, already correct). Verification: new 15-case GNU differential 4/15 -> 14/15 (only declare-abort case 3 remains, reserved for #635's fatal channel; message bytes already exact there); new tests/issue636_atstar_compound.rs (9 tests); focused suites green; full serial failure-set gate vs ea9c18e identical (NEW=0/DISAPPEARED=0 both levels); niubash A/B identical apart from the known load-flaky timing test (passes in isolation).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(executor): reject [@]/[*] in compound assignment before arithmetic eval (#636)
What
a+=( [@]=q )aborted on both shells, but GNU says[@]=q: cannot assign to non-numeric indexwhile rubash said@: arithmetic syntax error.GNU rejects ALL_ELEMENT_SUB before arithmetic eval, naming the whole
element word (
arrayfunc.c:786-792); rubash fell through to evalexp.Fix
Two guards (preexpanded + declare compound arms), matching the resolved
subscript exactly (
[@],['@'],[$k], both=/+=tails) beforeeval_indexed_subscript_expression, emitting<word>: cannot assign to non-numeric indexviadiagnostic_prefix(report_error channel, nocommand:segment — same as the #631err_badarraysubfix). No abort:like the
[]=arm,Errcarries GNU's break (partial store kept, evalcontains it — which also fixes the eval-escape for this branch; the
a[-2]=qescape stays with #637). Assoc@never reaches the guards(structurally excluded — the assoc arms return first);
[ @ ]staysarithmetic (exact match, no trim); single
a[@]=vuntouched (differentGNU owner,
arrayfunc.c:355-360, already correct).Verification
one remaining case is
declare -a d=( [@]=q )continuing with rc 0 —the message bytes are now exact; the abandon itself is declare -a a=( [-2]=q ) / local -a a=( [-2]=q ) still drop an out-of-range negative subscript (builtin route of #631) #635's builtin
fatal channel (the pre-existing
[]=gap on that route behavesidentically today).
tests/issue636_atstar_compound.rs(9 tests): whole-word message +abort + partial-store (via eval, matching GNU containment) + all three
controls. The declare test pins message bytes only, with the declare -a a=( [-2]=q ) / local -a a=( [-2]=q ) still drop an out-of-range negative subscript (builtin route of #631) #635
pointer.
full serial failure-set gate vs
ea9c18e: target sets identical(NEW=0/DISAPPEARED=0; branch +1 ok = the new test file), test-level
NEW=∅ / DISAPPEARED=∅ — the cleanest gate of the campaign so far.
6295367, only rubash[patch]switched): failure sets identical apart from the known load-flaky 50x
timing-ratio test (passes in isolation on the failing leg).
GNU owners:
arrayfunc.c:786-792(+array.h:177 ALL_ELEMENT_SUB),arrayfunc.c:355-360(single-element route, untouched).