diff --git a/src/cmd/gc/subr.c b/src/cmd/gc/subr.c index b233a0d8e5..884bb439d8 100644 --- a/src/cmd/gc/subr.c +++ b/src/cmd/gc/subr.c @@ -1928,13 +1928,14 @@ assignop(Type *src, Type *dst, char **why) } return 0; } + if(isptrto(dst, TINTER)) { + if(why != nil) + *why = smprint(":\n\t%T is pointer to interface, not interface", dst); + return 0; + } if(src->etype == TINTER && dst->etype != TBLANK) { - if(why != nil) { - if(isptrto(dst, TINTER)) - *why = smprint(":\n\t%T is interface, not pointer to interface", src); - else - *why = ": need type assertion"; - } + if(why != nil) + *why = ": need type assertion"; return 0; } diff --git a/test/interface/pointer.go b/test/interface/pointer.go index e628b558ea..076469c8de 100644 --- a/test/interface/pointer.go +++ b/test/interface/pointer.go @@ -33,4 +33,5 @@ func main() { print("call addinst\n") var x Inst = AddInst(new(Start)) // ERROR "pointer to interface" print("return from addinst\n") + var x *Inst = new(Start) // ERROR "pointer to interface" }