Skip to content

Commit aa72769

Browse files
committed
cmd/compile/internal/staticinit: fix panic in interface conversion
This patch fixes a panic from incorrect interface conversion from *ir.BasicLit to *ir.ConstExpr. This only occurs when nounified GOEXPERIMENT is set, so ideally it should be backported to Go 1.20 and removed from master. Fixes #58339
1 parent f9da938 commit aa72769

File tree

1 file changed

+4
-2
lines changed
  • src/cmd/compile/internal/staticinit

1 file changed

+4
-2
lines changed

src/cmd/compile/internal/staticinit/sched.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -870,8 +870,10 @@ func subst(n ir.Node, m map[*ir.Name]ir.Node) (ir.Node, bool) {
870870
// on variables are not valid on constants, so we might have
871871
// generated invalid code that will trip up the rest of the compiler.
872872
// Fix those by truncating the constants.
873-
if x, ok := truncate(x.X.(*ir.ConstExpr), x.Type()); ok {
874-
return x
873+
if ce, ok := x.X.(*ir.ConstExpr); ok {
874+
if x, ok := truncate(ce, x.Type()); ok {
875+
return x
876+
}
875877
}
876878
valid = false
877879
return x

0 commit comments

Comments
 (0)