Commit 299874d5 by Ian Lance Taylor

compiler: Method names must be non-blank.

Fixes issue 8078.

From-SVN: r216347
parent aa194848
...@@ -1253,6 +1253,8 @@ Parse::method_spec(Typed_identifier_list* methods) ...@@ -1253,6 +1253,8 @@ Parse::method_spec(Typed_identifier_list* methods)
if (this->advance_token()->is_op(OPERATOR_LPAREN)) if (this->advance_token()->is_op(OPERATOR_LPAREN))
{ {
// This is a MethodName. // This is a MethodName.
if (name == "_")
error_at(this->location(), "methods must have a unique non-blank name");
name = this->gogo_->pack_hidden_name(name, is_exported); name = this->gogo_->pack_hidden_name(name, is_exported);
Type* type = this->signature(NULL, location); Type* type = this->signature(NULL, location);
if (type == NULL) if (type == NULL)
......
...@@ -83,12 +83,12 @@ var m4 = M(jj) // ERROR "invalid|wrong type for M method" ...@@ -83,12 +83,12 @@ var m4 = M(jj) // ERROR "invalid|wrong type for M method"
type B1 interface { type B1 interface {
_() _() // ERROR "methods must have a unique non-blank name"
} }
type B2 interface { type B2 interface {
M() M()
_() _() // ERROR "methods must have a unique non-blank name"
} }
type T2 struct{} type T2 struct{}
......
...@@ -14,7 +14,6 @@ type I interface { ...@@ -14,7 +14,6 @@ type I interface {
func main() { func main() {
shouldPanic(p1) shouldPanic(p1)
shouldPanic(p2)
} }
func p1() { func p1() {
...@@ -30,19 +29,6 @@ type S struct{} ...@@ -30,19 +29,6 @@ type S struct{}
func (s *S) _() {} func (s *S) _() {}
type B interface {
_()
}
func p2() {
var s *S
var b B
var e interface{}
e = s
b = e.(B)
_ = b
}
func shouldPanic(f func()) { func shouldPanic(f func()) {
defer func() { defer func() {
if recover() == nil { if recover() == nil {
......
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