From 2744155d369ca838be57d1eba90c3c6bfc4a3b30 Mon Sep 17 00:00:00 2001 From: Cuong Manh Le Date: Sat, 7 Oct 2023 22:54:50 +0700 Subject: [PATCH] cmd/compile: fix ICE with parenthesized builtin calls CL 419456 starts using lookupObj to find types2.Object associated with builtin functions. However, the new code does not un-parenthesized the callee expression, causing an ICE because of nil obj returned. Un-parenthesizing the callee expression fixes the problem. Fixes #63436 Change-Id: Iebb4fbc08575e7d0b1dbd026c98e8f949ca16460 Reviewed-on: https://go-review.googlesource.com/c/go/+/533476 Auto-Submit: Cuong Manh Le Reviewed-by: Keith Randall LUCI-TryBot-Result: Go LUCI Reviewed-by: Matthew Dempsky Reviewed-by: Keith Randall --- src/cmd/compile/internal/noder/writer.go | 2 +- test/fixedbugs/issue63436.go | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/fixedbugs/issue63436.go diff --git a/src/cmd/compile/internal/noder/writer.go b/src/cmd/compile/internal/noder/writer.go index 6d7bd4c7821..08da36eccbb 100644 --- a/src/cmd/compile/internal/noder/writer.go +++ b/src/cmd/compile/internal/noder/writer.go @@ -1909,7 +1909,7 @@ func (w *writer) expr(expr syntax.Expr) { var rtype types2.Type if tv.IsBuiltin() { - switch obj, _ := lookupObj(w.p, expr.Fun); obj.Name() { + switch obj, _ := lookupObj(w.p, syntax.Unparen(expr.Fun)); obj.Name() { case "make": assert(len(expr.ArgList) >= 1) assert(!expr.HasDots) diff --git a/test/fixedbugs/issue63436.go b/test/fixedbugs/issue63436.go new file mode 100644 index 00000000000..bbd34a5a286 --- /dev/null +++ b/test/fixedbugs/issue63436.go @@ -0,0 +1,9 @@ +// compile + +// Copyright 2023 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package p + +var _ = (new)(int)