diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go index 54fcb2b830d..339ea77509a 100644 --- a/src/cmd/compile/internal/inline/inl.go +++ b/src/cmd/compile/internal/inline/inl.go @@ -1194,6 +1194,8 @@ func (subst *inlsubst) clovar(n *ir.Name) *ir.Name { case *ir.AssignStmt, *ir.AssignListStmt: // Mark node for reassignment at the end of inlsubst.node. m.Defn = &subst.defnMarker + case *ir.TypeSwitchGuard: + // TODO(mdempsky): Set m.Defn properly. See discussion on #45743. default: base.FatalfAt(n.Pos(), "unexpected Defn: %+v", defn) } diff --git a/test/fixedbugs/issue45743.go b/test/fixedbugs/issue45743.go new file mode 100644 index 00000000000..0b30e0f2a4d --- /dev/null +++ b/test/fixedbugs/issue45743.go @@ -0,0 +1,20 @@ +// compile + +// Copyright 2021 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package main + +func fn() func(interface{}) { + return func(o interface{}) { + switch v := o.(type) { + case *int: + *v = 1 + } + } +} + +func main() { + fn() +}