]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: pop instantiations of local types when leaving scope
authorDan Scales <danscales@google.com>
Thu, 16 Dec 2021 02:42:00 +0000 (18:42 -0800)
committerDan Scales <danscales@google.com>
Tue, 4 Jan 2022 22:05:15 +0000 (22:05 +0000)
commite39ab9b01cbbdac0750fc13fa8fb1de4f07aa79a
treec7e463a24424ee65f7a31acaca5bc51725508830
parent1c8f9d2c97db7390a7ed2cd4663571b544147f4d
cmd/compile: pop instantiations of local types when leaving scope

Since we use existing instantiations from the symbol table when possible
(to make sure each instantiation is unique), we need to pop
instantiations of local types when leaving the containing scope.
g.stmts() now pushes and pops scope, and we do a Pushdcl() in g.typ0()
when creating an instantiation of a local type.

Non-instantiated local types (generic or not) are translated directly
from types2, so they don't need to be pushed/popped. We don't export
function bodies with local types, so there is no issue during import.

We still don't support local types in generic functions/methods.

Fixes #50177

Change-Id: If2d2fe71aec003d13f0338565c7a0da2c9580a14
Reviewed-on: https://go-review.googlesource.com/c/go/+/372654
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/compile/internal/noder/stmt.go
src/cmd/compile/internal/noder/types.go
test/typeparam/issue50177.go [new file with mode: 0644]