Skip to content

formatter: preserve variadic call arguments#3

Merged
bhandras merged 1 commit into
masterfrom
codex/preserve-variadic-call-args
Jul 16, 2026
Merged

formatter: preserve variadic call arguments#3
bhandras merged 1 commit into
masterfrom
codex/preserve-variadic-call-args

Conversation

@bhandras

Copy link
Copy Markdown
Owner

Summary

  • preserve the trailing ... when AST-based call reflow rebuilds a variadic call
  • apply the same handling across structured-log, multiline-layout, packed, left-flow, and method-chain formatting paths
  • add regression coverage for structured calls and general multiline calls, including idempotence and AST-equivalence checks

Root cause

Go stores a call's variadic ellipsis on ast.CallExpr.Ellipsis, separately from the final expression in ast.CallExpr.Args. The affected reflow paths rendered only the argument expressions, so the final slice expression survived while its ... marker was omitted.

Impact

Formatting now preserves slice expansion semantics instead of silently turning the final expanded slice into an ordinary positional argument.

Testing

  • make self-check
  • make lint

The Go AST stores a call's ellipsis separately from its final argument.

Carry that marker through every AST-based call reflow path.

This prevents formatting from silently changing variadic-call semantics.
@bhandras
bhandras marked this pull request as ready for review July 16, 2026 14:17
@bhandras
bhandras merged commit d42cc6c into master Jul 16, 2026
2 checks passed
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