Skip to content

Commit b0cf591

Browse files
committed
fall back to dynamic dispatch in union-splitting optimization
This should help #17932. If a function returns an unanticipated type that wasn't part of the `Union` seen by inference, do dynamic dispatch instead of erroring.
1 parent f73e6e1 commit b0cf591

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

base/inference.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ const MAX_TUPLETYPE_LEN = 15
99
const MAX_TUPLE_DEPTH = 4
1010

1111
const MAX_TUPLE_SPLAT = 16
12-
const MAX_UNION_SPLITTING = 6
12+
const MAX_UNION_SPLITTING = 4
13+
const UNION_SPLIT_MISMATCH_ERROR = false
1314

1415
# alloc_elim_pass! relies on `Slot_AssignedOnce | Slot_UsedUndef` being
1516
# SSA. This should be true now but can break if we start to track conditional
@@ -2429,7 +2430,7 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference
24292430
all = false
24302431
end
24312432
end
2432-
if all
2433+
if UNION_SPLIT_MISMATCH_ERROR && all
24332434
error_label === nothing && (error_label = genlabel(sv))
24342435
push!(stmts, GotoNode(error_label.label))
24352436
else

0 commit comments

Comments
 (0)