diff options
| author | Russ Cox <rsc@golang.org> | 2008-10-08 09:21:57 -0700 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2008-10-08 09:21:57 -0700 |
| commit | b4f8e01acb8239eb8d31017d5f137cbda57e62d3 (patch) | |
| tree | ba4db825dc2016fbeb114668b1447487be5fdbaf /test | |
| parent | 638233a7d67d527c4f3e9465a18357264f1571ae (diff) | |
| download | go-b4f8e01acb8239eb8d31017d5f137cbda57e62d3.tar.xz | |
more interface checks:
- pointer to interface cannot have methods
- record type names for better runtime error
R=r,ken
DELTA=85 (80 added, 0 deleted, 5 changed)
OCL=16658
CL=16722
Diffstat (limited to 'test')
| -rw-r--r-- | test/golden.out | 15 | ||||
| -rw-r--r-- | test/interface1.go | 37 | ||||
| -rw-r--r-- | test/interface2.go | 23 |
3 files changed, 75 insertions, 0 deletions
diff --git a/test/golden.out b/test/golden.out index 9e8cbcf2ed..5fcde59824 100644 --- a/test/golden.out +++ b/test/golden.out @@ -2,6 +2,20 @@ =========== ./helloworld.go hello, world +=========== ./interface1.go +./interface1.go:5: syntax error near package +./interface1.go:31: illegal types for operand: AS + interface { Next () (*Inst) } + *Inst + +=========== ./interface2.go +cannot convert type S to interface I: missing method Foo +throw: interface conversion +SIGSEGV: segmentation violation +Faulting address: 0x0 +pc: xxx + + =========== ./peano.go 0! = 1 1! = 1 @@ -64,6 +78,7 @@ BUG: compilation should succeed =========== bugs/bug074.go bugs/bug074.go:6: syntax error near string +bugs/bug074.go:6: syntax error near string bugs/bug074.go:7: x: undefined BUG: compiler crashes - Bus error diff --git a/test/interface1.go b/test/interface1.go new file mode 100644 index 0000000000..a6430cd1b6 --- /dev/null +++ b/test/interface1.go @@ -0,0 +1,37 @@ +// errchk $G $D/$F.go + +// Copyright 2009 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 + +package main + +type Inst interface { + Next() *Inst; +} + +type Regexp struct { + code *[]Inst; + start Inst; +} + +type Start struct { + foo *Inst; +} + +func (start *Start) Next() *Inst { return nil } + + +func AddInst(Inst) *Inst { + print("ok in addinst\n"); + return nil +} + +func main() { + re := new(Regexp); + print("call addinst\n"); + var x Inst = AddInst(new(Start)); + print("return from addinst\n"); +} diff --git a/test/interface2.go b/test/interface2.go new file mode 100644 index 0000000000..8dfc9d8ff5 --- /dev/null +++ b/test/interface2.go @@ -0,0 +1,23 @@ +// $G $D/$F.go && $L $F.$A && ! ./$A.out + +// Copyright 2009 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 S struct + +type I interface { + Foo() +} + +func main() { + var s *S; + var i I; + i = s; +} + +// hide S down here to avoid static warning +type S struct { +} |
