From ee623e44b974e9d7a1e6ba89dc092b97c131f9fd Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Tue, 30 Aug 2016 19:29:52 -0400 Subject: [PATCH] remove pessimistic "UNION_SPLIT_MISMATCH_ERROR" from inference --- base/inference.jl | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/base/inference.jl b/base/inference.jl index 9444ad0a049d3..0d91d4127ee28 100644 --- a/base/inference.jl +++ b/base/inference.jl @@ -10,7 +10,6 @@ const MAX_TUPLE_DEPTH = 4 const MAX_TUPLE_SPLAT = 16 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 @@ -834,13 +833,6 @@ function abstract_call_gf_by_type(f::ANY, atype::ANY, sv::InferenceState) return Any end x::Array{Any,1} = applicable - if isempty(x) - # no methods match - # TODO: it would be nice to return Bottom here, but during bootstrap we - # often compile code that calls methods not defined yet, so it is much - # safer just to fall back on dynamic dispatch. - return Any - end fullmatch = false for (m::SimpleVector) in x sig = m[1]::DataType @@ -965,7 +957,10 @@ function abstract_call_gf_by_type(f::ANY, atype::ANY, sv::InferenceState) # added that did not intersect with any existing method add_mt_backedge(ft.name.mt, argtype, sv) end - # if rettype is Bottom we've found a method not found error + if isempty(x) + # TODO: this is needed because type intersection is wrong in some cases + return Any + end #print("=> ", rettype, "\n") return rettype end @@ -2627,7 +2622,7 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference all = false end end - if UNION_SPLIT_MISMATCH_ERROR && all + if all error_label === nothing && (error_label = genlabel(sv)) push!(stmts, GotoNode(error_label.label)) else @@ -2646,7 +2641,7 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference append!(stmts, match) if error_label !== nothing push!(stmts, error_label) - push!(stmts, Expr(:call, GlobalRef(_topmod(sv.mod), :error), "error in type inference due to #265")) + push!(stmts, Expr(:call, GlobalRef(_topmod(sv.mod), :error), "fatal error in type inference (type bound)")) end local ret_var, merge if spec_miss !== nothing @@ -2910,7 +2905,7 @@ function inlineable(f::ANY, ft::ANY, e::Expr, atypes::Vector{Any}, sv::Inference lastexpr = pop!(body.args) if isa(lastexpr,LabelNode) push!(body.args, lastexpr) - push!(body.args, Expr(:call, GlobalRef(_topmod(sv.mod),:error), "fatal error in type inference")) + push!(body.args, Expr(:call, GlobalRef(_topmod(sv.mod), :error), "fatal error in type inference (lowering)")) lastexpr = nothing elseif !(isa(lastexpr,Expr) && lastexpr.head === :return) # code sometimes ends with a meta node, e.g. inbounds pop