Repository navigation
fix(parser): assignment as a parenthesised call argument stops at the comma - #19
Merged
Merged
Conversation
… comma A parenthesised call/array argument list gathered an assignment's right-hand side across commas into an implicit array, so `f(a = 1, b = 2, 3)` parsed as a single argument `a = [1, b = [2, 3]]` instead of the three arguments `a = 1`, `b = 2`, `3`. The comma inside `(…)` / `[…]` separates arguments (or elements), so multiple-assignment detection must be off there — exactly as the paren-less parseCommandArgs and the def parameter-default / keyword-argument-value paths already do. parseCallArgs now suppresses masgn detection (p.noMasgn) for the span of the argument list, so an assignment argument's value stops at the comma. A parenthesised sub-expression re-enters a statement context and restores masgn, so `f((a, b = 1, 2))` is unaffected, and a top-level `x = 1, 2, 3` still gathers its array RHS. This is the standard mspec idiom for the mutating converter methods, e.g. `ec.primitive_convert(src = +"…", dst = +"", nil, 10)`, which failed with "no implicit conversion of Array into String". go vet, the full suite and the 100% coverage gate stay green. Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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.
A parenthesised call/array argument list gathered an assignment's right-hand side across commas into an implicit array, so
f(a = 1, b = 2, 3)parsed as a single argumenta = [1, b = [2, 3]]instead of the three argumentsa = 1,b = 2,3.The comma inside
(…)/[…]separates arguments (or elements), so multiple-assignment detection must be off there — exactly as the paren-lessparseCommandArgsand thedefparameter-default / keyword-argument-value paths already do.parseCallArgsnow suppresses masgn detection (p.noMasgn) for the span of the argument list.Unaffected:
f((a, b = 1, 2))still parses as a multiple assignment;x = 1, 2, 3still gathers its array RHS;f(a = 1)single-assignment arguments anddefdefaults.This is the standard mspec idiom for the mutating converter methods, e.g.
ec.primitive_convert(src = +"…", dst = +"", nil, 10), which failed downstream withno implicit conversion of Array into String.New tests
TestParenCallArgAssign/TestParenArrayElemAssign;go vet, the full suite and the 100% merged-coverage gate stay green.