2012-02-16 21:50:37 -07:00
|
|
|
// errorcheck
|
2008-10-08 10:21:57 -06:00
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
2012-02-18 23:33:41 -07:00
|
|
|
// Test that interface{M()} = *interface{M()} produces a compiler error.
|
|
|
|
// Does not compile.
|
2009-05-12 17:09:47 -06:00
|
|
|
|
2008-10-08 10:21:57 -06:00
|
|
|
package main
|
|
|
|
|
2009-01-20 15:40:40 -07:00
|
|
|
type Inst interface {
|
2010-06-08 19:50:02 -06:00
|
|
|
Next() *Inst
|
2008-10-08 10:21:57 -06:00
|
|
|
}
|
|
|
|
|
2009-01-20 15:40:40 -07:00
|
|
|
type Regexp struct {
|
2010-06-08 19:50:02 -06:00
|
|
|
code []Inst
|
|
|
|
start Inst
|
2008-10-08 10:21:57 -06:00
|
|
|
}
|
|
|
|
|
2009-01-20 15:40:40 -07:00
|
|
|
type Start struct {
|
2010-06-08 19:50:02 -06:00
|
|
|
foo *Inst
|
2008-10-08 10:21:57 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
func (start *Start) Next() *Inst { return nil }
|
|
|
|
|
2009-01-20 15:40:40 -07:00
|
|
|
func AddInst(Inst) *Inst {
|
2010-06-08 19:50:02 -06:00
|
|
|
print("ok in addinst\n")
|
2008-10-08 10:21:57 -06:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2010-06-08 19:50:02 -06:00
|
|
|
print("call addinst\n")
|
2020-12-01 18:37:12 -07:00
|
|
|
var x Inst = AddInst(new(Start)) // ERROR "pointer to interface|incompatible type"
|
2010-06-08 19:50:02 -06:00
|
|
|
print("return from addinst\n")
|
2021-09-22 22:57:19 -06:00
|
|
|
var y *Inst = new(Start) // ERROR "pointer to interface|incompatible type"
|
2008-10-08 10:21:57 -06:00
|
|
|
}
|