diff --git a/base/compiler/optimize.jl b/base/compiler/optimize.jl index 3a8de06811cc26..7c8413ceaf9af5 100644 --- a/base/compiler/optimize.jl +++ b/base/compiler/optimize.jl @@ -561,7 +561,7 @@ function convert_to_ircode(ci::CodeInfo, sv::OptimizationState) idx += 1 prevloc = codeloc end - if code[idx] isa Expr && ssavaluetypes[idx] === Union{} + if ssavaluetypes[idx] === Union{} && code[idx] !== nothing && !(code[idx] isa Core.Const) if !(idx < length(code) && isa(code[idx + 1], ReturnNode) && !isdefined((code[idx + 1]::ReturnNode), :val)) # insert unreachable in the same basic block after the current instruction (splitting it) insert!(code, idx + 1, ReturnNode())