modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/issue11790.go (about) 1 // compile 2 3 // Copyright 2015 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 11790: Incorrect error following named pointer dereference on field 8 9 package main 10 11 import "fmt" 12 13 type T0 struct { 14 x int 15 } 16 17 func (*T0) M0() { 18 fmt.Println("M0") 19 } 20 21 type T2 struct { 22 *T0 23 } 24 25 type Q *T2 26 27 func main() { 28 // If run, expected output is 29 // 42 30 // M0 31 t0 := T0{42} 32 t2 := T2{&t0} 33 var q Q = &t2 34 fmt.Println(q.x) // Comment out either this line or the next line and the program works 35 (*q).T0.M0() 36 }