diff options
Diffstat (limited to 'test/fixedbugs')
-rw-r--r-- | test/fixedbugs/bug226.dir/y.go | 2 | ||||
-rw-r--r-- | test/fixedbugs/bug322.dir/lib.go | 15 | ||||
-rw-r--r-- | test/fixedbugs/bug322.dir/main.go | 40 | ||||
-rw-r--r-- | test/fixedbugs/bug322.go | 8 | ||||
-rw-r--r-- | test/fixedbugs/bug337.go | 19 | ||||
-rw-r--r-- | test/fixedbugs/bug338.go | 22 | ||||
-rw-r--r-- | test/fixedbugs/bug339.go | 20 | ||||
-rw-r--r-- | test/fixedbugs/bug340.go | 17 | ||||
-rw-r--r-- | test/fixedbugs/bug341.go | 22 | ||||
-rw-r--r-- | test/fixedbugs/bug342.go | 24 | ||||
-rw-r--r-- | test/fixedbugs/bug343.go | 33 |
11 files changed, 221 insertions, 1 deletions
diff --git a/test/fixedbugs/bug226.dir/y.go b/test/fixedbugs/bug226.dir/y.go index 01e8b7b43..c66d592b7 100644 --- a/test/fixedbugs/bug226.dir/y.go +++ b/test/fixedbugs/bug226.dir/y.go @@ -15,7 +15,7 @@ func f() { _ = x.T{}; _ = x.T{Y:2}; - ok1.M(); // ERROR "assignment.*T" + ok1.M(); bad1 := *ok; // ERROR "assignment.*T" bad2 := ok1; // ERROR "assignment.*T" *ok4 = ok1; // ERROR "assignment.*T" diff --git a/test/fixedbugs/bug322.dir/lib.go b/test/fixedbugs/bug322.dir/lib.go new file mode 100644 index 000000000..0de56d3d6 --- /dev/null +++ b/test/fixedbugs/bug322.dir/lib.go @@ -0,0 +1,15 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package lib + +type T struct { + x int // non-exported field +} + +func (t T) M() { +} + +func (t *T) PM() { +} diff --git a/test/fixedbugs/bug322.dir/main.go b/test/fixedbugs/bug322.dir/main.go new file mode 100644 index 000000000..f403c7d32 --- /dev/null +++ b/test/fixedbugs/bug322.dir/main.go @@ -0,0 +1,40 @@ +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +import "./lib" + +type I interface { + M() +} + +type PI interface { + PM() +} + +func main() { + var t lib.T + t.M() + t.PM() + + // This is still an error. + // var i1 I = t + // i1.M() + + // This combination is illegal because + // PM requires a pointer receiver. + // var pi1 PI = t + // pi1.PM() + + var pt = &t + pt.M() + pt.PM() + + var i2 I = pt + i2.M() + + var pi2 PI = pt + pi2.PM() +} diff --git a/test/fixedbugs/bug322.go b/test/fixedbugs/bug322.go new file mode 100644 index 000000000..ad0e62dc8 --- /dev/null +++ b/test/fixedbugs/bug322.go @@ -0,0 +1,8 @@ +// $G $D/$F.dir/lib.go && $G $D/$F.dir/main.go && $L main.$A && ./$A.out || echo BUG: fails incorrectly + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Test case for issue 1402. +ignored diff --git a/test/fixedbugs/bug337.go b/test/fixedbugs/bug337.go new file mode 100644 index 000000000..62e310e72 --- /dev/null +++ b/test/fixedbugs/bug337.go @@ -0,0 +1,19 @@ +// errchk $G $D/$F.go + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 1722. + +// Check that the error messages says +// bug337.go:16: len("foo") not used +// and not +// bug337.go:16: 3 not used + +package main + +func main() { + len("foo") // ERROR "len" +} + diff --git a/test/fixedbugs/bug338.go b/test/fixedbugs/bug338.go new file mode 100644 index 000000000..c368a7fad --- /dev/null +++ b/test/fixedbugs/bug338.go @@ -0,0 +1,22 @@ +// $G $D/$F.go + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 1787. + +package main + +import "unsafe" + +const x = unsafe.Sizeof([8]byte{}) + +func main() { + var b [x]int + _ = b +} + +/* +bug338.go:14: array bound must be non-negative +*/ diff --git a/test/fixedbugs/bug339.go b/test/fixedbugs/bug339.go new file mode 100644 index 000000000..eac7c5ee6 --- /dev/null +++ b/test/fixedbugs/bug339.go @@ -0,0 +1,20 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 1608. +// Size used to be -1000000000. + +package main + +import "unsafe" + +func main() { + var a interface{} = 0 + size := unsafe.Sizeof(a) + if size != 2*unsafe.Sizeof((*int)(nil)) { + println("wrong size: ", size) + } +} diff --git a/test/fixedbugs/bug340.go b/test/fixedbugs/bug340.go new file mode 100644 index 000000000..461cc6cd4 --- /dev/null +++ b/test/fixedbugs/bug340.go @@ -0,0 +1,17 @@ +// errchk $G $D/$F.go + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 1606. + +package main + +func main() { + var x interface{} + switch t := x.(type) { // ERROR "0 is not a type" + case 0: + t.x = 1 // ERROR "type interface \{ \}" + } +} diff --git a/test/fixedbugs/bug341.go b/test/fixedbugs/bug341.go new file mode 100644 index 000000000..8ee52e1ef --- /dev/null +++ b/test/fixedbugs/bug341.go @@ -0,0 +1,22 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug341 + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Used to panic because 8g was generating incorrect +// code for converting a negative float to a uint64. + +package main + +func main() { + var x float32 = -2.5 + + _ = uint64(x) + _ = float32(0) +} +/* +panic: runtime error: floating point error + +[signal 0x8 code=0x6 addr=0x8048c64 pc=0x8048c64] +*/ diff --git a/test/fixedbugs/bug342.go b/test/fixedbugs/bug342.go new file mode 100644 index 000000000..0852cdd34 --- /dev/null +++ b/test/fixedbugs/bug342.go @@ -0,0 +1,24 @@ +// errchk $G $D/$F.go + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Issue 1871. + +package p + +type a interface { + foo(x int) (x int) // ERROR "redeclared|redefinition" +} + +var b interface { + bar(y int) (y int) // ERROR "redeclared|redefinition" +} + +/* +Previously: + +bug.go:1 x redclared in this block + previous declaration at bug.go:1 +*/ diff --git a/test/fixedbugs/bug343.go b/test/fixedbugs/bug343.go new file mode 100644 index 000000000..efc87e3d7 --- /dev/null +++ b/test/fixedbugs/bug343.go @@ -0,0 +1,33 @@ +// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug343 + +// Copyright 2011 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// issue 1900 + +package main + +func getArgs(data map[string]interface{}, keys ...string) map[string]string { + ret := map[string]string{} + var ok bool + for _, k := range keys { + ret[k], ok = data[k].(string) + if !ok {} + } + return ret +} + +func main() { + x := getArgs(map[string]interface{}{"x":"y"}, "x") + if x["x"] != "y" { + println("BUG bug343", x) + } +} + + +/* +typecheck [1008592b0] +. INDREG a(1) l(15) x(24) tc(2) runtime.ret G0 string +bug343.go:15: internal compiler error: typecheck INDREG +*/ |