]> Cypherpunks repositories - gostls13.git/commit
cmd/compile/internal/syntax: handle missing index like in go/parser
authorRobert Griesemer <gri@golang.org>
Wed, 17 Aug 2022 23:48:07 +0000 (16:48 -0700)
committerRobert Griesemer <gri@google.com>
Thu, 18 Aug 2022 21:46:39 +0000 (21:46 +0000)
commit9485d4c1bd871be792d03c29b7902f6ac284ed27
tree62555aa26887fe9db24148e1727f592b8c76abbe
parent39ec97da15e9167e7a17746c643f264baae6ce7b
cmd/compile/internal/syntax: handle missing index like in go/parser

Instead of simply reporting an error but otherwise dropping the
index expression from the parse tree when an index is missing
(as in: x[]), create an index expression with a "bad expression"
as index. This matches the behavior of go/parser and permits the
use of the same test case for both parsers.

(It would be simpler to adjust the go/parser to match the syntax
parser's behavior, but that would break backward-compatibility
of the go/parser.)

Adjust the affected test files.

For #54511.

Change-Id: If7668973794604593e869a24b560da92e100b812
Reviewed-on: https://go-review.googlesource.com/c/go/+/424654
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
src/cmd/compile/internal/syntax/parser.go
src/cmd/compile/internal/types2/testdata/examples/functions.go
src/cmd/compile/internal/types2/testdata/fixedbugs/issue39634.go
src/go/types/testdata/fixedbugs/issue39634.go