Permalink
Browse files

gc: correct receiver in method missing error

Fixes #1324.

R=rsc1, r, rsc
CC=golang-dev
https://golang.org/cl/3435042
  • Loading branch information...
lorenzo-stoakes authored and rsc committed Feb 11, 2011
1 parent 26880d7 commit b57ac97c27e8c5b8b9ff0e11c6dec538faa3eb43
Showing with 23 additions and 2 deletions.
  1. +3 −2 src/cmd/gc/typecheck.c
  2. +20 −0 test/fixedbugs/bug322.go
@@ -96,7 +96,7 @@ typecheck(Node **np, int top)
Node *n, *l, *r;
NodeList *args;
int lno, ok, ntop;
Type *t, *missing, *have;
Type *t, *tp, *missing, *have;
Sym *sym;
Val v;
char *why;
@@ -552,6 +552,7 @@ typecheck(Node **np, int top)
ok = Erv;
goto ret;
}
tp = t;
if(isptr[t->etype] && t->type->etype != TINTER) {
t = t->type;
if(t == T)
@@ -563,7 +564,7 @@ typecheck(Node **np, int top)
if(lookdot(n, t, 1))
yyerror("%#N undefined (cannot refer to unexported field or method %S)", n, n->right->sym);
else
yyerror("%#N undefined (type %T has no field or method %S)", n, t, n->right->sym);
yyerror("%#N undefined (type %T has no field or method %S)", n, tp, n->right->sym);
goto error;
}
switch(n->op) {
@@ -0,0 +1,20 @@
// errchk $G $D/$F.go
// Copyright 2011 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.
package main
type T struct{}
type P *T
func (t *T) Meth() {}
func (t T) Meth2() {}
func main() {
t := &T{}
p := P(t)
p.Meth() // ERROR "undefined \(type P"
p.Meth2() // ERROR "undefined \(type P"
}

0 comments on commit b57ac97

Please sign in to comment.