From eb57536c4c0e0b15779241e1f7ddab3c3c1569ec Mon Sep 17 00:00:00 2001 From: Jameson Nash Date: Tue, 30 Aug 2016 19:29:52 -0400 Subject: [PATCH] remove pessimistic "no method matches right now" from inference --- base/inference.jl | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/base/inference.jl b/base/inference.jl index 028fc37dde9f7..19434a21ba3b4 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 @@ -818,13 +817,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] @@ -2535,7 +2527,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 @@ -2554,7 +2546,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 @@ -2781,7 +2773,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