summaryrefslogtreecommitdiff
path: root/test/fixedbugs
diff options
context:
space:
mode:
Diffstat (limited to 'test/fixedbugs')
-rw-r--r--test/fixedbugs/bug177.go2
-rw-r--r--test/fixedbugs/bug248.dir/bug2.go4
-rw-r--r--test/fixedbugs/bug324.dir/main.go53
-rw-r--r--test/fixedbugs/bug324.dir/p.go15
-rw-r--r--test/fixedbugs/bug324.go8
-rw-r--r--test/fixedbugs/bug328.go14
-rw-r--r--test/fixedbugs/bug329.go46
-rw-r--r--test/fixedbugs/bug330.go13
-rw-r--r--test/fixedbugs/bug331.go36
-rw-r--r--test/fixedbugs/bug332.go17
-rw-r--r--test/fixedbugs/bug333.go19
-rw-r--r--test/fixedbugs/bug334.go31
-rw-r--r--test/fixedbugs/bug335.dir/a.go9
-rw-r--r--test/fixedbugs/bug335.dir/b.go11
-rw-r--r--test/fixedbugs/bug335.go10
-rw-r--r--test/fixedbugs/bug336.go86
16 files changed, 371 insertions, 3 deletions
diff --git a/test/fixedbugs/bug177.go b/test/fixedbugs/bug177.go
index aec382388..a120ad0ab 100644
--- a/test/fixedbugs/bug177.go
+++ b/test/fixedbugs/bug177.go
@@ -12,7 +12,7 @@ type S1 struct{ i int }
type S2 struct{ S1 }
func main() {
- typ := reflect.Typeof(S2{})
+ typ := reflect.TypeOf(S2{})
f := typ.Field(0)
if f.Name != "S1" || f.Anonymous != true {
println("BUG: ", f.Name, f.Anonymous)
diff --git a/test/fixedbugs/bug248.dir/bug2.go b/test/fixedbugs/bug248.dir/bug2.go
index 4ea187a4b..b6c816a5c 100644
--- a/test/fixedbugs/bug248.dir/bug2.go
+++ b/test/fixedbugs/bug248.dir/bug2.go
@@ -38,11 +38,11 @@ func main() {
// meaning that reflect data for v0, v1 didn't get confused.
// path is full (rooted) path name. check suffix for gc, prefix for gccgo
- if s := reflect.Typeof(v0).PkgPath(); !strings.HasSuffix(s, "/bug0") && !strings.HasPrefix(s, "bug0") {
+ if s := reflect.TypeOf(v0).PkgPath(); !strings.HasSuffix(s, "/bug0") && !strings.HasPrefix(s, "bug0") {
println("bad v0 path", len(s), s)
panic("fail")
}
- if s := reflect.Typeof(v1).PkgPath(); !strings.HasSuffix(s, "/bug1") && !strings.HasPrefix(s, "bug1") {
+ if s := reflect.TypeOf(v1).PkgPath(); !strings.HasSuffix(s, "/bug1") && !strings.HasPrefix(s, "bug1") {
println("bad v1 path", s)
panic("fail")
}
diff --git a/test/fixedbugs/bug324.dir/main.go b/test/fixedbugs/bug324.dir/main.go
new file mode 100644
index 000000000..3ab61f3eb
--- /dev/null
+++ b/test/fixedbugs/bug324.dir/main.go
@@ -0,0 +1,53 @@
+// 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 (
+ "./p"
+)
+
+type Exported interface {
+ private()
+}
+
+type Implementation struct{}
+
+func (p *Implementation) private() {}
+
+
+func main() {
+ // nothing unusual here
+ var x Exported
+ x = new(Implementation)
+ x.private() // main.Implementation.private()
+
+ // same here - should be and is legal
+ var px p.Exported
+ px = p.X
+
+ // this assignment is correctly illegal:
+ // px.private undefined (cannot refer to unexported field or method private)
+ // px.private()
+
+ // this assignment is correctly illegal:
+ // *Implementation does not implement p.Exported (missing p.private method)
+ // px = new(Implementation)
+
+ // this assignment is correctly illegal:
+ // p.Exported does not implement Exported (missing private method)
+ // x = px
+
+ // this assignment unexpectedly compiles and then executes
+ defer func() {
+ recover()
+ }()
+ x = px.(Exported)
+
+ println("should not get this far")
+
+ // this is a legitimate call, but because of the previous assignment,
+ // it invokes the method private in p!
+ x.private() // p.Implementation.private()
+}
diff --git a/test/fixedbugs/bug324.dir/p.go b/test/fixedbugs/bug324.dir/p.go
new file mode 100644
index 000000000..d1e3b991a
--- /dev/null
+++ b/test/fixedbugs/bug324.dir/p.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 p
+
+type Exported interface {
+ private()
+}
+
+type Implementation struct{}
+
+func (p *Implementation) private() { println("p.Implementation.private()") }
+
+var X = new(Implementation)
diff --git a/test/fixedbugs/bug324.go b/test/fixedbugs/bug324.go
new file mode 100644
index 000000000..3da75630a
--- /dev/null
+++ b/test/fixedbugs/bug324.go
@@ -0,0 +1,8 @@
+// $G $D/$F.dir/p.go && $G $D/$F.dir/main.go && $L main.$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.
+
+// Test case for issue 1550
+ignored
diff --git a/test/fixedbugs/bug328.go b/test/fixedbugs/bug328.go
new file mode 100644
index 000000000..64041f412
--- /dev/null
+++ b/test/fixedbugs/bug328.go
@@ -0,0 +1,14 @@
+// $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.
+
+package main
+
+import "unsafe"
+
+func main() {
+ var p unsafe.Pointer
+ println(p)
+}
diff --git a/test/fixedbugs/bug329.go b/test/fixedbugs/bug329.go
new file mode 100644
index 000000000..0b7074d62
--- /dev/null
+++ b/test/fixedbugs/bug329.go
@@ -0,0 +1,46 @@
+// $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.
+
+package main
+
+type Value struct {
+ X interface{}
+ Y int
+}
+
+type Struct struct {
+ X complex128
+}
+
+const magic = 1 + 2i
+
+func (Value) Complex(x complex128) {
+ if x != magic {
+ println(x)
+ panic("bad complex magic")
+ }
+}
+
+func f(x *byte, y, z int) complex128 {
+ return magic
+}
+
+func (Value) Struct(x Struct) {
+ if x.X != magic {
+ println(x.X)
+ panic("bad struct magic")
+ }
+}
+
+func f1(x *byte, y, z int) Struct {
+ return Struct{magic}
+}
+
+func main() {
+ var v Value
+ v.Struct(f1(nil, 0, 0)) // ok
+ v.Complex(f(nil, 0, 0)) // used to fail
+}
diff --git a/test/fixedbugs/bug330.go b/test/fixedbugs/bug330.go
new file mode 100644
index 000000000..cf1d6cc2d
--- /dev/null
+++ b/test/fixedbugs/bug330.go
@@ -0,0 +1,13 @@
+// errchk $G -e $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.
+
+package main
+
+func main() {
+ x := ""
+ x = +"hello" // ERROR "invalid operation.*string"
+ x = +x // ERROR "invalid operation.*string"
+}
diff --git a/test/fixedbugs/bug331.go b/test/fixedbugs/bug331.go
new file mode 100644
index 000000000..28aee1da0
--- /dev/null
+++ b/test/fixedbugs/bug331.go
@@ -0,0 +1,36 @@
+// $G $D/$F.go && $L $F.$A && ./$A.out || echo BUG: bug331
+
+// 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 "os"
+
+func f() (_ string, x float64, err os.Error) {
+ return
+}
+
+func g() (_ string, x float64, err os.Error) {
+ return "hello", 3.14, os.EOF
+}
+
+var _ func() (string, float64, os.Error) = f
+var _ func() (string, float64, os.Error) = g
+
+func main() {
+ x, y, z := g()
+ if x != "hello" || y != 3.14 || z != os.EOF {
+ println("wrong", x, len(x), y, z)
+ }
+}
+
+/*
+issue 1712
+
+bug331.go:12: cannot use "hello" (type string) as type float64 in assignment
+bug331.go:12: cannot use 0 (type float64) as type os.Error in assignment:
+ float64 does not implement os.Error (missing String method)
+bug331.go:12: error in shape across RETURN
+*/
diff --git a/test/fixedbugs/bug332.go b/test/fixedbugs/bug332.go
new file mode 100644
index 000000000..be79286b8
--- /dev/null
+++ b/test/fixedbugs/bug332.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.
+
+package main
+
+// type T int
+
+func main() {}
+
+// issue 1474
+
+// important: no newline on end of next line.
+// 6g used to print <epoch> instead of bug332.go:111
+func (t *T) F() {} // ERROR "bug332" \ No newline at end of file
diff --git a/test/fixedbugs/bug333.go b/test/fixedbugs/bug333.go
new file mode 100644
index 000000000..515c1f3fa
--- /dev/null
+++ b/test/fixedbugs/bug333.go
@@ -0,0 +1,19 @@
+// $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 1709
+
+package main
+
+func main() {
+ type Ts string
+ var ts Ts
+ _ = []byte(ts)
+}
+
+/*
+bug333.go:14: cannot use ts (type Ts) as type string in function argument
+*/
diff --git a/test/fixedbugs/bug334.go b/test/fixedbugs/bug334.go
new file mode 100644
index 000000000..870c9ae24
--- /dev/null
+++ b/test/fixedbugs/bug334.go
@@ -0,0 +1,31 @@
+// $G $D/$F.go || echo BUG: bug334
+
+// 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 1716
+
+package main
+
+type (
+ cplx64 complex64
+ cplx128 complex128
+)
+
+func (c cplx64) Foo() {}
+func (c cplx128) Foo() {}
+
+func main() {
+ var c64 cplx128
+ var c128 cplx64
+ c64.Foo()
+ c128.Foo()
+}
+
+/*
+bug334.go:16: invalid receiver type cplx64
+bug334.go:17: invalid receiver type cplx128
+bug334.go:22: c64.Foo undefined (type cplx128 has no field or method Foo)
+bug334.go:23: c128.Foo undefined (type cplx64 has no field or method Foo)
+*/
diff --git a/test/fixedbugs/bug335.dir/a.go b/test/fixedbugs/bug335.dir/a.go
new file mode 100644
index 000000000..5a8112a9d
--- /dev/null
+++ b/test/fixedbugs/bug335.dir/a.go
@@ -0,0 +1,9 @@
+// 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 a
+
+import "./b"
+
+var Bar = b.Foo
diff --git a/test/fixedbugs/bug335.dir/b.go b/test/fixedbugs/bug335.dir/b.go
new file mode 100644
index 000000000..7428c2a91
--- /dev/null
+++ b/test/fixedbugs/bug335.dir/b.go
@@ -0,0 +1,11 @@
+// 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 b
+
+type T interface{}
+
+func f() T { return nil }
+
+var Foo T = f()
diff --git a/test/fixedbugs/bug335.go b/test/fixedbugs/bug335.go
new file mode 100644
index 000000000..915b74657
--- /dev/null
+++ b/test/fixedbugs/bug335.go
@@ -0,0 +1,10 @@
+// $G $D/$F.dir/b.go && $G $D/$F.dir/a.go
+// rm -f a.$A b.$A
+
+// 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 1705.
+
+unused (see script at top of file)
diff --git a/test/fixedbugs/bug336.go b/test/fixedbugs/bug336.go
new file mode 100644
index 000000000..8de36898f
--- /dev/null
+++ b/test/fixedbugs/bug336.go
@@ -0,0 +1,86 @@
+// $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.
+
+package main
+
+type T1 struct {
+ Next *T2
+}
+
+type T2 T1
+
+type T3 struct {
+ Next *T4
+}
+
+type T4 T5
+type T5 T6
+type T6 T7
+type T7 T8
+type T8 T9
+type T9 T3
+
+type T10 struct {
+ x struct {
+ y ***struct {
+ z *struct {
+ Next *T11
+ }
+ }
+ }
+}
+
+type T11 T10
+
+type T12 struct {
+ F1 *T15
+ F2 *T13
+ F3 *T16
+}
+
+type T13 T14
+type T14 T15
+type T15 T16
+type T16 T17
+type T17 T12
+
+// issue 1672
+type T18 *[10]T19
+type T19 T18
+
+func main() {
+ _ = &T1{&T2{}}
+ _ = &T2{&T2{}}
+ _ = &T3{&T4{}}
+ _ = &T4{&T4{}}
+ _ = &T5{&T4{}}
+ _ = &T6{&T4{}}
+ _ = &T7{&T4{}}
+ _ = &T8{&T4{}}
+ _ = &T9{&T4{}}
+ _ = &T12{&T15{}, &T13{}, &T16{}}
+
+ var (
+ tn struct{ Next *T11 }
+ tz struct{ z *struct{ Next *T11 } }
+ tpz *struct{ z *struct{ Next *T11 } }
+ tppz **struct{ z *struct{ Next *T11 } }
+ tpppz ***struct{ z *struct{ Next *T11 } }
+ ty struct {
+ y ***struct{ z *struct{ Next *T11 } }
+ }
+ )
+ tn.Next = &T11{}
+ tz.z = &tn
+ tpz = &tz
+ tppz = &tpz
+ tpppz = &tppz
+ ty.y = tpppz
+ _ = &T10{ty}
+
+ t19s := &[10]T19{}
+ _ = T18(t19s)
+}