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
27func AddInst(Inst) *Inst {
28	print("ok in addinst\n")
29	return nil
30}
31
32func main() {
33	print("call addinst\n")
34	var _ Inst = AddInst(new(Start)) // ERROR "pointer to interface|incompatible type"
35	print("return from  addinst\n")
36	var _ *Inst = new(Start) // ERROR "pointer to interface|incompatible type"
37}
38