Fixes #76103.
Change-Id: Idc2f5d1d7aeb4a9b468e7c268e3bf5b85d1c3777
Reviewed-on: https://go-review.googlesource.com/c/go/+/716300
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Error:
x.mode = invalid
+ x.typ = Typ[Invalid]
x.expr = e
}
Error:
x.mode = invalid
+ x.typ = Typ[Invalid]
x.expr = e
}
--- /dev/null
+// Copyright 2025 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
+
+func _() {
+ f(foo /* ERROR "undefined: foo" */) // ERROR "not enough arguments in call to f\n\thave (unknown type)\n\twant (int, int)"
+}
+
+func f(_, _ int) {}
+
+// test case from issue
+
+type S struct{}
+
+func (S) G() {}
+
+func main() {
+ var s S
+ _ = must(s.F /* ERROR "s.F undefined" */ ()) // ERROR "not enough arguments in call to must\n\thave (unknown type)\n\twant (T, error)"
+}
+
+func must[T any](x T, err error) T {
+ if err != nil {
+ panic(err)
+ }
+ return x
+}