]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/compile/internal/types2: return an error from Instantiate
authorRobert Findley <rfindley@google.com>
Fri, 13 Aug 2021 19:52:12 +0000 (15:52 -0400)
committerRobert Findley <rfindley@google.com>
Thu, 19 Aug 2021 15:05:05 +0000 (15:05 +0000)
commit69d8fbec7ab74b3b0f8b689a9a251bdf621936aa
treedfcf4bf1cd282419062e1754d188c3bc7b32b2ea
parent3bdc1799d6ce441d7a972faf1452e34b6dce0826
cmd/compile/internal/types2: return an error from Instantiate

Change Instantiate to be a function (not a method) and return an error.
Introduce an ArgumentError type to report information about which type
argument led to an error during verification.

This resolves a few concerns with the current API:
 - The Checker method set was previously just Files. It is somewhat odd
   to add an additional method for instantiation. Passing the checker as
   an argument seems cleaner.
 - pos, posList, and verify were bound together. In cases where no
   verification is required, the call site was somewhat cluttered.
 - Callers will likely want to access structured information about why
   type information is invalid, and also may not have access to position
   information. Returning an argument index solves both these problems;
   if callers want to associate errors with an argument position, they
   can do this via the resulting index.

We may want to make the first argument an opaque environment rather than
a Checker.

Change-Id: I3bc56d205c13d832b538401a4c91d3917c041225
Reviewed-on: https://go-review.googlesource.com/c/go/+/342152
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/importer/iimport.go
src/cmd/compile/internal/noder/reader2.go
src/cmd/compile/internal/types2/api.go
src/cmd/compile/internal/types2/api_test.go
src/cmd/compile/internal/types2/call.go
src/cmd/compile/internal/types2/instantiate.go
src/cmd/compile/internal/types2/named.go
src/cmd/compile/internal/types2/subst.go
src/cmd/compile/internal/types2/typexpr.go