Source file test/abi/open_defer_1.go

     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  
     9  package main
    10  
    11  func main() {
    12  	var x, y, z int = -1, -2, -3
    13  	F(x, y, z)
    14  }
    15  
    16  //go:noinline
    17  func F(x, y, z int) {
    18  	defer i.M(x, y, z)
    19  	defer func() { recover() }()
    20  	panic("XXX")
    21  }
    22  
    23  type T int
    24  
    25  func (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  
    32  var t T = 42
    33  
    34  type I interface{ M(x, y, z int) }
    35  
    36  var i I = &t
    37  

View as plain text