]> Cypherpunks repositories - gostls13.git/commit
go/types: match types2 string when printing composite literals
authorRobert Griesemer <gri@golang.org>
Sat, 20 Aug 2022 01:31:56 +0000 (18:31 -0700)
committerRobert Griesemer <gri@golang.org>
Thu, 25 Aug 2022 17:31:33 +0000 (17:31 +0000)
commit83b5fe63514411f425061967fd8c1d506f2ac40f
treeb6816fb167f8a2465e91ae69d018382ae9317426
parent1df2a03b17b4496bddfb482ec45b2a29c20e5249
go/types: match types2 string when printing composite literals

Given a composite literal type S, rather than always printing
(S literal) for a composite literals, print S{} if the literal
has no elements, and print S{…} as a short form (suitable for
error messages) if there are elements. This matches types2 and
also Go1.17 compiler behavior (except that the original compiler
would print ... rather than …). Using … rather than ... makes
it clearer that we don't have real Go syntax, and it's also more
compact.

For #54511.

Change-Id: I5991e8060232f16ecbf4a1fe4ae091598fc76b68
Reviewed-on: https://go-review.googlesource.com/c/go/+/425006
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/types/api_test.go
src/go/types/exprstring.go
src/go/types/exprstring_test.go
src/go/types/testdata/check/decls3.go
src/go/types/testdata/check/decls4.go
src/go/types/testdata/check/issues0.go
src/go/types/testdata/fixedbugs/issue49579.go