]> Cypherpunks repositories - gostls13.git/commit
go/types: return an error from Instantiate on incorrect len(targs)
authorRobert Findley <rfindley@google.com>
Fri, 12 Nov 2021 16:46:23 +0000 (11:46 -0500)
committerRobert Findley <rfindley@google.com>
Sat, 13 Nov 2021 01:39:23 +0000 (01:39 +0000)
commitc78a267bd4ccdd8699a9dbe9bad3597bf3de47e9
treed1c51c2677650e43795dc62419f0951aa42baf92
parente658c42ba460b91d5b6934829ddffa802d4ca524
go/types: return an error from Instantiate on incorrect len(targs)

Instantiate already returns an error when validation fails. Panicking on
an incorrect number of type arguments means that callers must both
pre-validate the number of type arguments and handle resulting errors.
Returning an error rather than panicking allows eliminating
pre-validation at the call-site.

Also update the Instantiate docstring to correct some stale/inaccurate
information, and to clarify its behavior more precisely.

Updates #47916

Change-Id: I997ef30b3486760a90b0db4c3ea7111280d74a81
Reviewed-on: https://go-review.googlesource.com/c/go/+/363635
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/go/types/instantiate.go