Commit 53fa2d27 by Ian Lance Taylor

compiler: Disallow call of *T method using **T variable.

Fixes https://code.google.com/p/go/issues/detail?id=8583.

From-SVN: r214560
parent fadc8afc
...@@ -9453,10 +9453,11 @@ Type::bind_field_or_method(Gogo* gogo, const Type* type, Expression* expr, ...@@ -9453,10 +9453,11 @@ Type::bind_field_or_method(Gogo* gogo, const Type* type, Expression* expr,
else else
go_unreachable(); go_unreachable();
go_assert(m != NULL); go_assert(m != NULL);
if (dereferenced && m->is_value_method()) if (dereferenced)
{ {
error_at(location, error_at(location,
"calling value method requires explicit dereference"); "calling method %qs requires explicit dereference",
Gogo::message_name(name).c_str());
return Expression::make_error(location); return Expression::make_error(location);
} }
if (!m->is_value_method() && expr->type()->points_to() == NULL) if (!m->is_value_method() && expr->type()->points_to() == NULL)
......
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
package main package main
type T struct {} type T struct{}
func (t *T) pm() {} func (t *T) pm() {}
func (t T) m() {} func (t T) m() {}
func main() { func main() {
p := &T{} p := &T{}
...@@ -20,5 +20,5 @@ func main() { ...@@ -20,5 +20,5 @@ func main() {
q := &p q := &p
q.m() // ERROR "requires explicit dereference" q.m() // ERROR "requires explicit dereference"
q.pm() q.pm() // ERROR "requires explicit dereference"
} }
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