diff --git a/base/compiler/ssair/inlining.jl b/base/compiler/ssair/inlining.jl index 1dce18bc35393..902c567957eeb 100644 --- a/base/compiler/ssair/inlining.jl +++ b/base/compiler/ssair/inlining.jl @@ -492,8 +492,7 @@ function ir_inline_unionsplit!(compact::IncrementalCompact, idx::Int, end # We're now in the join block. - compact.ssa_rename[compact.idx-1] = insert_node_here!(compact, pn, typ, line) - nothing + return insert_node_here!(compact, pn, typ, line) end function batch_inline!(todo::Vector{Pair{Int, Any}}, ir::IRCode, linetable::Vector{LineInfoNode}, propagate_inbounds::Bool) @@ -548,7 +547,7 @@ function batch_inline!(todo::Vector{Pair{Int, Any}}, ir::IRCode, linetable::Vect if isa(item, InliningTodo) compact.ssa_rename[old_idx] = ir_inline_item!(compact, idx, argexprs, linetable, item, boundscheck, state.todo_bbs) elseif isa(item, UnionSplit) - ir_inline_unionsplit!(compact, idx, argexprs, linetable, item, boundscheck, state.todo_bbs) + compact.ssa_rename[old_idx] = ir_inline_unionsplit!(compact, idx, argexprs, linetable, item, boundscheck, state.todo_bbs) end compact[idx] = nothing refinish && finish_current_bb!(compact, 0) diff --git a/test/compiler/inline.jl b/test/compiler/inline.jl index 152aaac50d971..6aa95e242215d 100644 --- a/test/compiler/inline.jl +++ b/test/compiler/inline.jl @@ -331,3 +331,11 @@ struct NonIsBitsDimsUndef end @test Core.Compiler.is_inlineable_constant(NonIsBitsDimsUndef()) @test !Core.Compiler.is_inlineable_constant((("a"^1000, "b"^1000), nothing)) + +# Issue #42264 - crash on certain union splits +let f(x) = (x...,) + # Test splatting with a Union of non-{Tuple, SimpleVector} types that require creating new `iterate` calls + # in inlining. For this particular case, we're relying on `iterate(::CaretesianIndex)` throwing an error, such + # the the original apply call is not union-split, but the inserted `iterate` call is. + @test code_typed(f, Tuple{Union{Int64, CartesianIndex{1}, CartesianIndex{3}}})[1][2] == Tuple{Int64} +end