modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/bug401.go (about) 1 // run 2 3 // Copyright 2011 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 // Issue 2582 8 package main 9 10 type T struct{} 11 12 //go:noinline 13 func (T) cplx() complex128 { 14 return complex(1, 0) 15 } 16 17 func (T) cplx2() complex128 { 18 return complex(0, 1) 19 } 20 21 type I interface { 22 cplx() complex128 23 } 24 25 func main() { 26 27 var t T 28 29 if v := real(t.cplx()); v != 1 { 30 panic("not-inlined complex call failed") 31 } 32 _ = imag(t.cplx()) 33 34 _ = real(t.cplx2()) 35 if v := imag(t.cplx2()); v != 1 { 36 panic("potentially inlined complex call failed") 37 } 38 39 var i I 40 i = t 41 if v := real(i.cplx()); v != 1 { 42 panic("potentially inlined complex call failed") 43 } 44 _ = imag(i.cplx()) 45 }