diff options
author | Keith Randall <khr@golang.org> | 2021-04-26 14:13:19 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2021-04-27 19:30:11 +0000 |
commit | f432d3fc41b8f6b01131023aabcf935ebea172cb (patch) | |
tree | c1bc6adf07fba87d7e3e99763fd067a63b679299 /test | |
parent | 8ab7064e33667f17b8d23b5db63468199c3eac02 (diff) | |
download | go-f432d3fc41b8f6b01131023aabcf935ebea172cb.tar.gz go-f432d3fc41b8f6b01131023aabcf935ebea172cb.zip |
cmd/compile: fix nongeneric closures in generic functions
Ensure that formal parameter Names are correctly copied and marked
with the correct Curfn. We need to ensure this even when the underlying
closure has no type parameters.
(Aside: it is strange that the types of things contain formal
parameter names that need to be copied. Maybe that's an underlying
larger problem that needs to be fixed.)
Fixes #45738
Change-Id: Ia13d69eea992ff7080bd44065115bc52eb624e73
Reviewed-on: https://go-review.googlesource.com/c/go/+/313652
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/typeparam/issue45738.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/typeparam/issue45738.go b/test/typeparam/issue45738.go new file mode 100644 index 0000000000..9f03e796a3 --- /dev/null +++ b/test/typeparam/issue45738.go @@ -0,0 +1,18 @@ +// 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 main + +//go:noinline +func f[T any]() { + x := 5 + g := func() int { return x } + g() +} + +func main() { + f[int]() +} |