codekingpro/portable-devtools
114k
1// errorcheck2 3// Copyright 2009 The Go Authors. All rights reserved.4// Use of this source code is governed by a BSD-style5// 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 main11 12type Inst interface {13 Next() *Inst14}15 16type Regexp struct {17 code []Inst18 start Inst19}20 21type Start struct {22 foo *Inst23}24 25func (start *Start) Next() *Inst { return nil }26 27func AddInst(Inst) *Inst {28 print("ok in addinst\n")29 return nil30}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 