Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions Compiler/src/typeinfer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -613,18 +613,17 @@ function finishinfer!(me::InferenceState, interp::AbstractInterpreter, cycleid::
istoplevel = !(me.linfo.def isa Method)
istoplevel || compute_edges!(me) # don't add backedges to toplevel method instance

if limited_ret
# a parent may be cached still, but not this intermediate work:
# we can throw everything else away now
if limited_ret || limited_src
# A parent may be cached still, but not this intermediate work:
# we can throw everything else away now. Caching anything can confuse later
# heuristics to consider it worth trying to pursue compiling this further and
# finding infinite work as a result. Avoiding caching helps to ensure there is only
# a finite amount of work that can be discovered later (although potentially still a
# large multiplier on it).
result.src = nothing
result.tombstone = true
me.cache_mode = CACHE_MODE_NULL
set_inlineable!(me.src, false)
elseif limited_src
# a type result will be cached still, but not this intermediate work:
# we can throw everything else away now
result.src = nothing
set_inlineable!(me.src, false)
else
# annotate fulltree with type information,
# either because we are the outermost code, or we might use this later
Expand Down
25 changes: 25 additions & 0 deletions Compiler/test/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6445,4 +6445,29 @@ A58257.B58257.get! # Creates binding partition in A.B, N+1:∞
Base.invoke_in_world(UInt(38678), getglobal, A58257, :get!) # Expands binding partition in A through <N
@test Base.infer_return_type(A58257.f) == typeof(Base.get!) # Attempt to lookup A.B in world age N hangs

function tt57873(a::Vector{String}, pref)
ret = String[]
for j in a
append!(ret, tt57873(a[2:end], (pref..., "")))
end
return ret
end
let code = Compiler.typeinf_ext_toplevel(Any[Core.svec(Any,Tuple{typeof(tt57873),Vector{String},Tuple{String}})], [Base.get_world_counter()], Base.Compiler.TRIM_NO)
@test !isempty(code)
## If we were to run trim here, we should fail with:
# Verifier error #1: unresolved invoke from statement tt57873(::Vector{String}, ::Tuple{String, String})::Vector{String}
#Stacktrace:
# [1] tt57873(a::Vector{String}, pref::Tuple{String})
# @ Main REPL[1]:4
end

function ss57873(a::Vector{String}, pref)
ret = String[]
for j in a
append!(ret, ss57873(a[2:end], (pref..., "")))
end
return ret
end
@test ss57873(["a", "b", "c"], ("",)) == String[]

end # module inference