From b1d9ae9406e0217731665da622b7a29fadc3efbd Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Sun, 12 Feb 2012 20:03:30 -0800 Subject: [PATCH] go spec: method names must be unique Fixes #2916. R=golang-dev, remyoudompheng, r, rsc CC=golang-dev https://golang.org/cl/5652064 --- doc/go_spec.html | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/doc/go_spec.html b/doc/go_spec.html index 5aa14fc9551..fb96db7d3ee 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -662,7 +662,7 @@ The method set of the corresponding pointer type *T is the set of all methods with receiver *T or T (that is, it also contains the method set of T). Any other type has an empty method set. -In a method set, each method must have a unique name. +In a method set, each method must have a unique method name.

@@ -1862,11 +1862,13 @@ they can be used to declare local temporary variables (§S

Function declarations

-A function declaration binds an identifier to a function (§Function types). +A function declaration binds an identifier, the function name, +to a function.

-FunctionDecl = "func" identifier Signature [ Body ] .
+FunctionDecl = "func" FunctionName Signature [ Body ] .
+FunctionName = identifier .
 Body         = Block .
 
@@ -1890,8 +1892,10 @@ func flushICache(begin, end uintptr) // implemented externally

A method is a function with a receiver. -A method declaration binds an identifier to a method. +A method declaration binds an identifier, the method name, to a method. +It also associates the method with the receiver's base type.

+
 MethodDecl   = "func" Receiver MethodName Signature [ Body ] .
 Receiver     = "(" [ identifier ] [ "*" ] BaseTypeName ")" .
@@ -1900,13 +1904,18 @@ BaseTypeName = identifier .
 
 

The receiver type must be of the form T or *T where -T is a type name. T is called the -receiver base type or just base type. -The base type must not be a pointer or interface type and must be -declared in the same package as the method. -The method is said to be bound to the base type -and is visible only within selectors for that type -(§Type declarations, §Selectors). +T is a type name. The type denoted by T is called +the receiver base type; it must not be a pointer or interface type and +it must be declared in the same package as the method. +The method is said to be bound to the base type and the method name +is visible only within selectors for that type. +

+ +

+For a base type, the non-blank names of +methods bound to it must be unique. +If the base type is a struct type, +the non-blank method and field names must be distinct.