mirror of
https://github.com/golang/go
synced 2024-11-26 11:38:01 -07:00
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
This commit is contained in:
parent
c956dcdc54
commit
ced8004a00
@ -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;
|
||||
|
||||
|
20
test/fixedbugs/issue4458.go
Normal file
20
test/fixedbugs/issue4458.go
Normal file
@ -0,0 +1,20 @@
|
||||
// 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"
|
||||
}
|
Loading…
Reference in New Issue
Block a user