[tools] go/analysis/passes/modernize: newexpr - fix panic

0 views
Skip to first unread message

Alan Donovan (Gerrit)

unread,
Jun 25, 2026, 3:09:24 PM (2 days ago) Jun 25
to Madeline Kalil, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, golang...@luci-project-accounts.iam.gserviceaccount.com, Michael Matloob, Robert Findley, Gopher Robot, golang-co...@googlegroups.com

Alan Donovan submitted the change

Change information

Commit message:
go/analysis/passes/modernize: newexpr - fix panic

The newexpr modernizer panics when it encounters
a variadic call with zero arguments. Avoid
the panic by skipping calls with zero args.

We can still transform variadic functions into
inlineable wrappers around new(expr)
because the inliner will correctly insert the array to
match the variadic params (the modernizer just replaces
the function name with "new" and doesn't transform
the arguments, so we would get something like new(1, 2)
if we directly modify the callsite).

Fixes golang/go#80110
Change-Id: I4d839713e38281f6e87092a7c4da87fdfe26d1d0
Commit-Queue: Alan Donovan <adon...@google.com>
Auto-Submit: Alan Donovan <adon...@google.com>
Reviewed-by: Alan Donovan <adon...@google.com>
Files:
  • M go/analysis/passes/modernize/newexpr.go
  • M go/analysis/passes/modernize/testdata/src/newexpr/newexpr.go
  • M go/analysis/passes/modernize/testdata/src/newexpr/newexpr.go.golden
Change size: S
Delta: 3 files changed, 9 insertions(+), 2 deletions(-)
Branch: refs/heads/master
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: tools
Gerrit-Branch: master
Gerrit-Change-Id: I4d839713e38281f6e87092a7c4da87fdfe26d1d0
Gerrit-Change-Number: 793362
Gerrit-PatchSet: 5
Gerrit-Owner: Madeline Kalil <mka...@google.com>
Gerrit-Reviewer: Alan Donovan <adon...@google.com>
Gerrit-Reviewer: Madeline Kalil <mka...@google.com>
Gerrit-CC: Gopher Robot <go...@golang.org>
Gerrit-CC: Michael Matloob <mat...@golang.org>
Gerrit-CC: Robert Findley <rfin...@golang.org>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages