]> Cypherpunks.ru repositories - gostls13.git/commit
go/types, types2: don't print function parameter names when showing type differences
authorRobert Griesemer <gri@golang.org>
Mon, 12 Sep 2022 22:04:20 +0000 (15:04 -0700)
committerGopher Robot <gobot@golang.org>
Tue, 13 Sep 2022 12:58:04 +0000 (12:58 +0000)
commitdad2966a83c1597786a96a8ef407ed412575ec94
treef2d4392ca667f0ac5e1cfa21ab2a1ccbf18902ad
parentc7a0b156592ca15612315fc71f4e287268643bfd
go/types, types2: don't print function parameter names when showing type differences

Add a new flag 'paramNames' to typeWriter struct to control whether
function parameter names are written or not (set by default). Unset
it when we want the function signature w/o parameter names, e.g. when
showing two signatures that are not identical. This makes is much
easier to see the typw differences in the error message.

To avoid needing to provide yet another (rarely used) boolean parameter
to typeString, remove that function in favor of setting the paramNames
flag explicitly. Adjust the code in errors.go that used typeString; the
resulting code is also more efficient (fewer bytes.Buffer allocations).

While at it, rename the typeWriter 'debug' field to 'tpSubscripts'
because that is what it controls.

Add test case and adjusted existing expected output for existing tests.

Fixes #54942.

Change-Id: I625eae30c403c39ce89951b8ea6214d783c92c75
Reviewed-on: https://go-review.googlesource.com/c/go/+/430416
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
src/cmd/compile/internal/types2/errors.go
src/cmd/compile/internal/types2/lookup.go
src/cmd/compile/internal/types2/typestring.go
src/go/types/errors.go
src/go/types/lookup.go
src/go/types/typestring.go
src/internal/types/testdata/check/issues0.go
src/internal/types/testdata/fixedbugs/54942.go [new file with mode: 0644]