1// errorcheck
2
3// Copyright 2009 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// Test that interface{M()} = *interface{M()} produces a compiler error.
8// Does not compile.
9
10package main
11
12type Inst interface {
13	Next() *Inst
14}
15
16type Regexp struct {
17	code  []Inst
18	start Inst
19}
20
21type Start struct {
22	foo *Inst
23}
24
25func (start *Start) Next() *Inst { return nil }
26
27
28func AddInst(Inst) *Inst {
29	print("ok in addinst\n")
30	return nil
31}
32
33func main() {
34	print("call addinst\n")
35	var x Inst = AddInst(new(Start)) // ERROR "pointer to interface"
36	print("return from  addinst\n")
37	var y *Inst = new(Start)  // ERROR "pointer to interface|incompatible type"
38}
39