aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/noder
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-09-24 08:57:06 -0700
committerDan Scales <danscales@google.com>2021-09-25 01:24:46 +0000
commit8854368cb076ea9a2b71c8b3c8f675a8e19b751c (patch)
tree2bc1f770b01ce1da5ab899ef61be769aac416d70 /src/cmd/compile/internal/noder
parentd60ad1e068263832c711aaf17b6ccb1b7f71b000 (diff)
downloadgo-8854368cb076ea9a2b71c8b3c8f675a8e19b751c.tar.xz
cmd/compile: deal with blank nodes with typeparam type during stenciling
Deal correctly with a blank local variable with type param type. This is a special case, because a blank local variable is not in the fn.Dcl list. In this case, we must explicitly create a new blank node with the correct substituted type, so we have correct types if the blank local variable has an initializing assignment. Fixes #48602 Change-Id: I903ea44b29934e180404e32800773b7309bf297b Reviewed-on: https://go-review.googlesource.com/c/go/+/352117 Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Dan Scales <danscales@google.com>
Diffstat (limited to 'src/cmd/compile/internal/noder')
-rw-r--r--src/cmd/compile/internal/noder/stencil.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/noder/stencil.go b/src/cmd/compile/internal/noder/stencil.go
index cf8641d60e..23f53bac04 100644
--- a/src/cmd/compile/internal/noder/stencil.go
+++ b/src/cmd/compile/internal/noder/stencil.go
@@ -912,6 +912,12 @@ func (subst *subster) node(n ir.Node) ir.Node {
if v := subst.ts.Vars[x.(*ir.Name)]; v != nil {
return v
}
+ if ir.IsBlank(x) {
+ // Special case, because a blank local variable is
+ // not in the fn.Dcl list.
+ m := ir.NewNameAt(x.Pos(), ir.BlankNode.Sym())
+ return typed(subst.ts.Typ(x.Type()), m)
+ }
return x
case ir.ONONAME:
// This handles the identifier in a type switch guard