modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/fixedbugs/issue8947.go (about) 1 // run 2 3 // Copyright 2014 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 // Some uses of zeroed constants in non-assignment 8 // expressions broke with our more aggressive zeroing 9 // of assignments (internal compiler errors). 10 11 package main 12 13 func f1() { 14 type T [2]int 15 p := T{0, 1} 16 switch p { 17 case T{0, 0}: 18 panic("wrong1") 19 case T{0, 1}: 20 // ok 21 default: 22 panic("wrong2") 23 } 24 25 if p == (T{0, 0}) { 26 panic("wrong3") 27 } else if p == (T{0, 1}) { 28 // ok 29 } else { 30 panic("wrong4") 31 } 32 } 33 34 type T struct { 35 V int 36 } 37 38 var X = T{}.V 39 40 func f2() { 41 var x = T{}.V 42 if x != 0 { 43 panic("wrongx") 44 } 45 if X != 0 { 46 panic("wrongX") 47 } 48 } 49 50 func main() { 51 f1() 52 f2() 53 }