Skip to content

fix(parser): assignment as a parenthesised call argument stops at the comma - #19

Merged
tannevaled merged 1 commit into
mainfrom
fix/paren-call-arg-masgn
Aug 30, 2026
Merged

tannevaled merged 1 commit into
mainfrom
fix/paren-call-arg-masgn

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

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.

Unaffected:

  • a parenthesised sub-expression re-enters a statement context and restores masgn, so f((a, b = 1, 2)) still parses as a multiple assignment;
  • a top-level x = 1, 2, 3 still gathers its array RHS;
  • f(a = 1) single-assignment arguments and def defaults.

This is the standard mspec idiom for the mutating converter methods, e.g. ec.primitive_convert(src = +"…", dst = +"", nil, 10), which failed downstream with no implicit conversion of Array into String.

New tests TestParenCallArgAssign / TestParenArrayElemAssign; go vet, the full suite and the 100% merged-coverage gate stay green.

… 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>
@tannevaled
tannevaled merged commit 8c972fc into main Aug 30, 2026
11 checks passed
@tannevaled
tannevaled deleted the fix/paren-call-arg-masgn branch August 30, 2026 10:20
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