diff --git a/base/compiler/ssair/legacy.jl b/base/compiler/ssair/legacy.jl index e94bc5f08aa6b..f8fce66bde49c 100644 --- a/base/compiler/ssair/legacy.jl +++ b/base/compiler/ssair/legacy.jl @@ -86,7 +86,7 @@ function replace_code_newstyle!(ci::CodeInfo, ir::IRCode, nargs::Int) elseif isa(stmt, GotoIfNot) code[i] = GotoIfNot(stmt.cond, first(ir.cfg.blocks[stmt.dest].stmts)) elseif isa(stmt, PhiNode) - code[i] = PhiNode(Int32[last(ir.cfg.blocks[edge].stmts) for edge in stmt.edges], stmt.values) + code[i] = PhiNode(Int32[edge == 0 ? 0 : last(ir.cfg.blocks[edge].stmts) for edge in stmt.edges], stmt.values) elseif isexpr(stmt, :enter) stmt.args[1] = first(ir.cfg.blocks[stmt.args[1]::Int].stmts) code[i] = stmt diff --git a/test/compiler/inference.jl b/test/compiler/inference.jl index 1c8b7c7be93a5..4311a63c66c1d 100644 --- a/test/compiler/inference.jl +++ b/test/compiler/inference.jl @@ -4111,3 +4111,15 @@ struct Issue45780 end f45780() = Val{Issue45780(@Base.Experimental.opaque ()->1).oc()}() @test (@inferred f45780()) == Val{1}() + +# issue #45600 +@test only(code_typed() do + while true + x = try finally end + end +end)[2] == Union{} +@test only(code_typed() do + while true + @time 1 + end +end)[2] == Union{}