]> Cypherpunks.ru repositories - gostls13.git/commit
go/types: better errors for invalid short var decls
authorRob Findley <rfindley@google.com>
Wed, 28 Apr 2021 14:35:53 +0000 (10:35 -0400)
committerRobert Findley <rfindley@google.com>
Wed, 28 Apr 2021 20:22:15 +0000 (20:22 +0000)
commit6082c05d8b4ab59e74204a3749629c8e6240b7b0
treeb1dc598d3147816558867f576c33e7c0dfb94fb2
parent414af503d7ec20cdfd6df23d5dee733401644ba3
go/types: better errors for invalid short var decls

This is a port of CL 312170 to go/types, adjusted to use go/ast and to
add error codes. go/parser already emits errors for non-identifiers on
the LHS of a short var decl, so a TODO is added to reconsider this
redundancy.

A new error code is added for repeated identifiers in short var decls.
This is a bit specific, but I considered it to be a unique kind of
error.

The x/tools tests for this port turned up a bug: the new logic failed to
call recordDef for blank identifiers. Patchset #2 contains the fix for
this bug, both in go/types and cmd/compile/internal/types2.

Change-Id: Ibdc40b8b4ad0e0696111d431682e1f1056fd5eeb
Reviewed-on: https://go-review.googlesource.com/c/go/+/314629
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/types2/api_test.go
src/cmd/compile/internal/types2/assignments.go
src/go/types/api_test.go
src/go/types/assignments.go
src/go/types/errorcodes.go
src/go/types/fixedbugs/issue43087.src [new file with mode: 0644]
src/go/types/testdata/stmt0.src