]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile/internal/syntax: remove code dealing with multiple method names
authorRobert Griesemer <gri@golang.org>
Wed, 30 Mar 2022 02:38:00 +0000 (19:38 -0700)
committerRobert Griesemer <gri@golang.org>
Wed, 30 Mar 2022 18:02:38 +0000 (18:02 +0000)
When parsing method declarations in an interface, the parser has
for historic reasons gracefully handled a list of method names with
a single (common) signature, and then reported an error. For example

        interface {
                m1, m2, m3 (x int)
        }

This code originally came from the very first parser for Go which
initially permitted such declarations (or at least assumed that
people would write such declarations). Nobody is doing this at this
point, so there's no need for being extra careful here. Remove the
respective code and adjust the corresponding test.

Change-Id: If6f9b398bbc9e425dcd4328a80d8bf77c37fe8b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/396654
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/compile/internal/syntax/parser.go
test/fixedbugs/bug121.go

index 2c53a40b2f97593a8eef4c76b4130d3cda2a4768..805bf13aff3ee1ff498dd5e7786e93855cbe56f6 100644 (file)
@@ -1725,20 +1725,6 @@ func (p *parser) methodDecl() *Field {
        f.pos = p.pos()
        name := p.name()
 
-       // accept potential name list but complain
-       // TODO(gri) We probably don't need this special check anymore.
-       //           Nobody writes this kind of code. It's from ancient
-       //           Go beginnings.
-       hasNameList := false
-       for p.got(_Comma) {
-               p.name()
-               hasNameList = true
-       }
-       if hasNameList {
-               p.syntaxError("name list not allowed in interface type")
-               // already progressed, no need to advance
-       }
-
        const context = "interface method"
 
        switch p.tok {
index 22c71817526236f9f01b1f2abeb6a987866dd7b0..471c27eb821e04e2c07c1e28ac0fe413a5c905bf 100644 (file)
@@ -9,7 +9,7 @@ package main
 type T func()
 
 type I interface {
-       f, g ();        // ERROR "name list not allowed"
+       f, g ();  // ERROR "unexpected comma"
 }
 
 type J interface {