Commit b57ac97c authored by Lorenzo Stoakes's avatar Lorenzo Stoakes Committed by Russ Cox

gc: correct receiver in method missing error

Fixes #1324.

R=rsc1, r, rsc
CC=golang-dev
https://golang.org/cl/3435042
parent 26880d7e
...@@ -96,7 +96,7 @@ typecheck(Node **np, int top) ...@@ -96,7 +96,7 @@ typecheck(Node **np, int top)
Node *n, *l, *r; Node *n, *l, *r;
NodeList *args; NodeList *args;
int lno, ok, ntop; int lno, ok, ntop;
Type *t, *missing, *have; Type *t, *tp, *missing, *have;
Sym *sym; Sym *sym;
Val v; Val v;
char *why; char *why;
...@@ -552,6 +552,7 @@ reswitch: ...@@ -552,6 +552,7 @@ reswitch:
ok = Erv; ok = Erv;
goto ret; goto ret;
} }
tp = t;
if(isptr[t->etype] && t->type->etype != TINTER) { if(isptr[t->etype] && t->type->etype != TINTER) {
t = t->type; t = t->type;
if(t == T) if(t == T)
...@@ -563,7 +564,7 @@ reswitch: ...@@ -563,7 +564,7 @@ reswitch:
if(lookdot(n, t, 1)) if(lookdot(n, t, 1))
yyerror("%#N undefined (cannot refer to unexported field or method %S)", n, n->right->sym); yyerror("%#N undefined (cannot refer to unexported field or method %S)", n, n->right->sym);
else 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; goto error;
} }
switch(n->op) { switch(n->op) {
......
// 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"
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment