]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: call types.CheckSize() in g.typ()
authorDan Scales <danscales@google.com>
Thu, 11 Mar 2021 03:28:28 +0000 (19:28 -0800)
committerDan Scales <danscales@google.com>
Fri, 12 Mar 2021 00:52:00 +0000 (00:52 +0000)
commit71a6c13164f2151c14ebaeccdfcb3633fc8b618e
tree2642f0e45b87b873ec8796a66aaee6258876646a
parent7fc638d6f1679f2e35862555531bf479c3e5b99c
cmd/compile:  call types.CheckSize() in g.typ()

Restore code to call types.CheckSize() in g.typ(). There are certain
cases (involving maps) where we need to do CheckSize here. In general,
the old typechecker calls CheckSize() a lot, and we want to eliminate
calling it eventually, so should get do types.CheckSize() when we create
a new concrete type.

However, the test typeparams/cons.go does not work with just calling
types.CheckSize() in g.typ() (which is why I disabled the calls
originally). The reason is that g.typ() is called recursively within
types.go, so it can be called on a partially-created recursive type,
which leads to an error in CheckSize(). So, we need to call CheckSize()
only on fully-created top-level types. So, I divided typ() into typ()
and typ1(), where typ() is now the external entry point, and typ1() is
called within types.go. Now, typ() can call CheckSize() safely.

I also added in an extra condition - we do not currently need to call
CheckSize() on non-fully-instantiated types, since they will not make it
to the backend.  That could change a bit with dictionaries.

Fixes #44895

Change-Id: I783aa7d2999dd882ddbd99a7c19a6ff6ee420102
Reviewed-on: https://go-review.googlesource.com/c/go/+/300989
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dan Scales <danscales@google.com>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/noder/types.go