Skip to content

Commit

Permalink
remove pessimistic "UNION_SPLIT_MISMATCH_ERROR" from inference
Browse files Browse the repository at this point in the history
  • Loading branch information
vtjnash committed Sep 23, 2016
1 parent d17785a commit ee623e4
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ee623e4

Please sign in to comment.