diff --git a/src/cmd/compile/internal/ir/expr.go b/src/cmd/compile/internal/ir/expr.go index c95ea36909a..112d3941ce4 100644 --- a/src/cmd/compile/internal/ir/expr.go +++ b/src/cmd/compile/internal/ir/expr.go @@ -748,13 +748,6 @@ func IsAddressable(n Node) bool { case ODEREF, ODOTPTR: return true - case OXDOT: - // TODO(danscales): remove this case as we remove calls to the old - // typechecker in (*irgen).funcBody(). - if base.Flag.G == 0 { - return false - } - fallthrough case ODOT: n := n.(*SelectorExpr) return IsAddressable(n.X) diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go index 329c80098a3..2745016545a 100644 --- a/src/cmd/compile/internal/noder/stencil.go +++ b/src/cmd/compile/internal/noder/stencil.go @@ -53,11 +53,15 @@ func (g *irgen) stencil() { continue } - case ir.OAS: - - case ir.OAS2: + case ir.OAS, ir.OAS2, ir.OAS2DOTTYPE, ir.OAS2FUNC, ir.OAS2MAPR, ir.OAS2RECV, ir.OASOP: + // These are all the various kinds of global assignments, + // whose right-hand-sides might contain a function + // instantiation. default: + // The other possible ops at the top level are ODCLCONST + // and ODCLTYPE, which don't have any function + // instantiations. continue } diff --git a/test/typeparam/issue45547.go b/test/typeparam/issue45547.go new file mode 100644 index 00000000000..0a08d66b70e --- /dev/null +++ b/test/typeparam/issue45547.go @@ -0,0 +1,20 @@ +// compile -G=3 + +// Copyright 2021 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[T any]() (f, g T) { return f, g } + +// Tests for generic function instantiation on the right hande side of multi-value +// assignments. + +func _() { + // Multi-value assignment within a function + var _, _ = f[int]() +} + +// Multi-value assignment outside a function. +var _, _ = f[int]()