1// run 2 3// Copyright 2021 The Go Authors. All rights reserved. 4// Use of this source code is governed by a BSD-style 5// license that can be found in the LICENSE file. 6 7// For #45062, miscompilation of open defer of method invocation 8 9package main 10 11func main() { 12 var x, y, z int = -1, -2, -3 13 F(x, y, z) 14} 15 16//go:noinline 17func F(x, y, z int) { 18 defer i.M(x, y, z) 19 defer func() { recover() }() 20 panic("XXX") 21} 22 23type T int 24 25func (t *T) M(x, y, z int) { 26 if x == -1 && y == -2 && z == -3 { 27 return 28 } 29 println("FAIL: Expected -1, -2, -3, but x, y, z =", x, y, z) 30} 31 32var t T = 42 33 34type I interface{ M(x, y, z int) } 35 36var i I = &t 37