x.expr = call
check.hasCallOrRecv = true
- // if type inference failed, a parametrized result must be invalidated
- // (operands cannot have a parametrized type)
+ // if type inference failed, a parameterized result must be invalidated
+ // (operands cannot have a parameterized type)
if x.mode == value && sig.TypeParams().Len() > 0 && isParameterized(sig.TypeParams().list(), x.typ) {
x.mode = invalid
}
case *Pointer:
return w.isParameterized(t.base)
- // case *Tuple:
- // This case should not occur because tuples only appear
- // in signatures where they are handled explicitly.
+ case *Tuple:
+ // This case does not occur from within isParameterized
+ // because tuples only appear in signatures where they
+ // are handled explicitly. But isParameterized is also
+ // called by Checker.callExpr with a function result tuple
+ // if instantiation failed (go.dev/issue/59890).
+ return t != nil && w.varList(t.vars)
case *Signature:
// t.tparams may not be nil if we are looking at a signature
x.expr = call
check.hasCallOrRecv = true
- // if type inference failed, a parametrized result must be invalidated
- // (operands cannot have a parametrized type)
+ // if type inference failed, a parameterized result must be invalidated
+ // (operands cannot have a parameterized type)
if x.mode == value && sig.TypeParams().Len() > 0 && isParameterized(sig.TypeParams().list(), x.typ) {
x.mode = invalid
}
case *Pointer:
return w.isParameterized(t.base)
- // case *Tuple:
- // This case should not occur because tuples only appear
- // in signatures where they are handled explicitly.
+ case *Tuple:
+ // This case does not occur from within isParameterized
+ // because tuples only appear in signatures where they
+ // are handled explicitly. But isParameterized is also
+ // called by Checker.callExpr with a function result tuple
+ // if instantiation failed (go.dev/issue/59890).
+ return t != nil && w.varList(t.vars)
case *Signature:
// t.tparams may not be nil if we are looking at a signature
--- /dev/null
+// 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
+
+func _() { g /* ERROR "cannot infer T" */ () }
+
+func g[T any]() (_ /* ERROR "cannot use _ as value or type" */, int) { panic(0) }
+
+// test case from issue
+
+var _ = append(f /* ERROR "cannot infer T" */ ()())
+
+func f[T any]() (_ /* ERROR "cannot use _" */, _ /* ERROR "cannot use _" */, int) {
+ panic("not implemented")
+}