From f10a7882c6d2876592bb73a27e7e595caad5c376 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Thu, 21 Apr 2011 08:20:29 -0400 Subject: [PATCH] gc: another pointer to interface message R=ken2 CC=golang-dev https://golang.org/cl/4444056 --- src/cmd/gc/subr.c | 13 +++++++------ test/interface/pointer.go | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) 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" }