mirror of
https://github.com/golang/go
synced 2024-11-17 20:04:47 -07:00
93f10b8829
For go/defer calls like "defer f(x, y)", the compiler rewrites it to: x1, y1 := x, y defer func() { f(x1, y1) }() However, if "f" needs runtime type information, the "RType" field will refer to the outer ".dict" param, causing wrong liveness analysis. To fix this, if "f" refers to outer ".dict", the dict param will be copied to an autotmp, and "f" will refer to this autotmp instead. Fixes #58341 Change-Id: I238b6e75441442b5540d39bc818205398e80c94d Reviewed-on: https://go-review.googlesource.com/c/go/+/466035 Reviewed-by: David Chase <drchase@google.com> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
31 lines
471 B
Go
31 lines
471 B
Go
// 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
|
|
|
|
type S[T comparable] struct {
|
|
m map[T]T
|
|
}
|
|
|
|
func (s S[T]) M1(node T) {
|
|
defer delete(s.m, node)
|
|
}
|
|
|
|
func (s S[T]) M2(node T) {
|
|
defer func() {
|
|
delete(s.m, node)
|
|
}()
|
|
}
|
|
|
|
func (s S[T]) M3(node T) {
|
|
defer f(s.m, node)
|
|
}
|
|
|
|
//go:noinline
|
|
func f[T comparable](map[T]T, T) {}
|
|
|
|
var _ = S[int]{}
|