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 11package main 12 13func 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 34type T struct { 35 V int 36} 37 38var X = T{}.V 39 40func f2() { 41 var x = T{}.V 42 if x != 0 { 43 panic("wrongx") 44 } 45 if X != 0 { 46 panic("wrongX") 47 } 48} 49 50func main() { 51 f1() 52 f2() 53} 54