]> Cypherpunks repositories - gostls13.git/commit
go/types, types2: don't panic when instantiating generic alias with wrong number...
authorRobert Griesemer <gri@golang.org>
Thu, 9 Jan 2025 23:01:03 +0000 (15:01 -0800)
committerGopher Robot <gobot@golang.org>
Mon, 13 Jan 2025 18:30:43 +0000 (10:30 -0800)
commit17ed2159583289d77c994d479c24f7e7c2837332
tree9b156c41da201e7305b111eec941a7130bdffa5f
parentc53307c3fdf1126eb6cdb1f09f4f9b83759be705
go/types, types2: don't panic when instantiating generic alias with wrong number of type arguments

The existing code assumed the type argument count check in
Checker.instance couldn't fail for generic alias types
(matching the code for generic signatures), but it actually
can.

Adjust the code accordingly and document that the result of
Checker.instance may be invalid.

Review all call sites of Checker.instance and make sure we
handle the failure case, or document the code accordingly
(in the case of generic signatures).

When reporting an type argument count error, use the alias
name rather than the alias string representation to match
the error we get for a non-alias type.

While at it, update the manual.go template for ease of use.

Fixes #71198.

Change-Id: I6d19ec6418440e9b49574a2d7dd9825e0af6c2fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/641857
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
src/cmd/compile/internal/types2/call.go
src/cmd/compile/internal/types2/instantiate.go
src/cmd/compile/internal/types2/testdata/manual.go
src/cmd/compile/internal/types2/typexpr.go
src/go/types/call.go
src/go/types/instantiate.go
src/go/types/testdata/manual.go
src/go/types/typexpr.go
src/internal/types/testdata/fixedbugs/issue71198.go [new file with mode: 0644]