Commit ced8004a authored by Rémy Oudompheng's avatar Rémy Oudompheng

cmd/gc: do not accept (**T).Method expressions.

The typechecking code was doing an extra, unnecessary
indirection.

Fixes #4458.

R=golang-dev, daniel.morsing, rsc
CC=golang-dev
https://golang.org/cl/6998051
parent c956dcdc
......@@ -1781,7 +1781,7 @@ lookdot1(Node *errnode, Sym *s, Type *t, Type *f, int dostrcmp)
static int
looktypedot(Node *n, Type *t, int dostrcmp)
{
Type *f1, *f2, *tt;
Type *f1, *f2;
Sym *s;
s = n->right->sym;
......@@ -1798,11 +1798,9 @@ looktypedot(Node *n, Type *t, int dostrcmp)
return 1;
}
tt = t;
if(t->sym == S && isptr[t->etype])
tt = t->type;
f2 = methtype(tt, 0);
// Find the base type: methtype will fail if t
// is not of the form T or *T.
f2 = methtype(t, 0);
if(f2 == T)
return 0;
......
// errorcheck
// Copyright 2012 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.
// Issue 4458: gc accepts invalid method expressions
// like (**T).Method.
package main
type T struct{}
func (T) foo() {}
func main() {
av := T{}
pav := &av
(**T).foo(&pav) // ERROR "no method foo"
}
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