Skip to content

Commit

Permalink
Revert "remove pessimistic "no method matches right now" from inference"
Browse files Browse the repository at this point in the history
This reverts commit eb57536.

This is a workaround for failed ambiguity detection in #18307.
  • Loading branch information
vtjnash committed Sep 21, 2016
1 parent 4070959 commit 8ec80fd
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions base/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ 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 @@ -846,6 +847,13 @@ 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 @@ -2556,7 +2564,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
Expand All @@ -2575,7 +2583,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), "fatal error in type inference (type bound)"))
push!(stmts, Expr(:call, GlobalRef(_topmod(sv.mod), :error), "error in type inference due to #265"))
end
local ret_var, merge
if spec_miss !== nothing
Expand Down Expand Up @@ -2838,7 +2846,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 (lowering)"))
push!(body.args, Expr(:call, GlobalRef(_topmod(sv.mod),:error), "fatal error in type inference"))
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 8ec80fd

Please sign in to comment.