]> Cypherpunks repositories - gostls13.git/commit
go/parser: allow trailing commas in embedded instantiated types
authorcia-rana <kiwamura0314@gmail.com>
Mon, 14 Nov 2022 08:01:03 +0000 (17:01 +0900)
committerRobert Griesemer <gri@google.com>
Thu, 17 Nov 2022 17:02:15 +0000 (17:02 +0000)
commitcafb49ac731f862f386862d64b27b8314eeb2909
tree4680d4377efb0099043236e4afd25e24e9108118
parentf3ae7ac9d90a26e9bba1589ae934e62bf0ac17e0
go/parser: allow trailing commas in embedded instantiated types

go/parser can correctly parse interfaces that instantiate and embed
generic interfaces, but not structs. This is because in the case of
structs, it does not expect RBRACK as a token trailing COMMA in the type
argument, even though it is allowed by the spec.

For example, go/parser produces an error for the type declaration below:

type A struct {
    B[byte, []byte,]
}

Fixes #56748

Change-Id: Ibb2addd6cf9b381d8470a6d20eedb93f13f93cd6
Reviewed-on: https://go-review.googlesource.com/c/go/+/450175
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
src/go/parser/parser.go
src/go/parser/testdata/tparams.go2