From fd14be9fd7143755dd24c5007f69efd2ded2b87a Mon Sep 17 00:00:00 2001 From: Jeff Bezanson Date: Tue, 16 Aug 2016 00:29:05 -0400 Subject: [PATCH] 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. (cherry picked from commit b0cf59170ceb4032c8a01c65b4f21ca878f566be) ref #18046 --- base/inference.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/base/inference.jl b/base/inference.jl index 79edb33b96cbd..2649514a32bd1 100644 --- a/base/inference.jl +++ b/base/inference.jl @@ -9,7 +9,8 @@ const MAX_TUPLETYPE_LEN = 15 const MAX_TUPLE_DEPTH = 4 const MAX_TUPLE_SPLAT = 16 -const MAX_UNION_SPLITTING = 6 +const MAX_UNION_SPLITTING = 4 +const UNION_SPLIT_MISMATCH_ERROR = false # alloc_elim_pass! relies on `Slot_AssignedOnce | Slot_UsedUndef` being # SSA. This should be true now but can break if we start to track conditional @@ -2437,7 +2438,7 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference all = false end end - if all + if UNION_SPLIT_MISMATCH_ERROR && all error_label === nothing && (error_label = genlabel(sv)) push!(stmts, GotoNode(error_label.label)) else