aboutsummaryrefslogtreecommitdiff
path: root/test/typeparam
diff options
context:
space:
mode:
authorCuong Manh Le <cuong.manhle.vn@gmail.com>2022-08-29 17:25:32 +0700
committerGopher Robot <gobot@golang.org>2022-08-30 17:23:27 +0000
commitddc93a536faf4576d182cd3197b116d61d05c484 (patch)
tree15b430fa0e677db158fe01574c95b5b29dd57187 /test/typeparam
parentc22865fcfa1ec434e5655c652c6376fa2d0eb821 (diff)
downloadgo-ddc93a536faf4576d182cd3197b116d61d05c484.tar.xz
cmd/compile: fix unified IR shapifying recursive instantiated types
Shape-based stenciling in unified IR is done by converting type argument to its underlying type. So it agressively check that type argument is not a TFORW. However, for recursive instantiated type argument, it may still be a TFORW when shapifying happens. Thus the assertion failed, causing the compiler crashing. To fix it, just allow fully instantiated type when shapifying. Fixes #54512 Fixes #54722 Change-Id: I527e3fd696388c8a37454e738f0324f0c2ec16cb Reviewed-on: https://go-review.googlesource.com/c/go/+/426335 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Heschi Kreinick <heschi@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Diffstat (limited to 'test/typeparam')
-rw-r--r--test/typeparam/nested.go26
1 files changed, 5 insertions, 21 deletions
diff --git a/test/typeparam/nested.go b/test/typeparam/nested.go
index 068e32be1d..cdb8bfb574 100644
--- a/test/typeparam/nested.go
+++ b/test/typeparam/nested.go
@@ -104,27 +104,11 @@ func main() {
F[V]()
F[W]()
- // TODO(go.dev/issue/54512): Restore these tests. They currently
- // cause problems for shaping with unified IR.
- //
- // For example, instantiating X[int] requires instantiating shape
- // type X[shapify(int)] == X[go.shape.int]. In turn, this requires
- // instantiating U[shapify(X[go.shape.int])]. But we're still in the
- // process of constructing X[go.shape.int], so we don't yet know its
- // underlying type.
- //
- // Notably, this is a consequence of unified IR writing out type
- // declarations with a reference to the full RHS expression (i.e.,
- // U[X[A]]) rather than its underlying type (i.e., int), which is
- // necessary to support //go:notinheap. Once go.dev/issue/46731 is
- // implemented and unified IR is updated, I expect this will just
- // work.
- //
- // type X[A any] U[X[A]]
- //
- // F[X[int]]()
- // F[X[Int]]()
- // F[X[GlobalInt]]()
+ type X[A any] U[X[A]]
+
+ F[X[int]]()
+ F[X[Int]]()
+ F[X[GlobalInt]]()
for j, tj := range tests {
for i, ti := range tests[:j+1] {