Skip to content

Commit

Permalink
fix nothrow modeling for invoke calls
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Sep 3, 2024
1 parent 7a65218 commit 6916bc1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2181,6 +2181,9 @@ function abstract_invoke(interp::AbstractInterpreter, arginfo::ArgInfo, si::Stmt
rt = from_interprocedural!(interp, rt, sv, arginfo, sig)
info = InvokeCallInfo(match, const_result)
edge !== nothing && add_invoke_backedge!(sv, lookupsig, edge)
if !match.fully_covers
effects = Effects(effects; nothrow=false)
end
return CallMeta(rt, Any, effects, info)
end

Expand Down
10 changes: 10 additions & 0 deletions test/compiler/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6109,3 +6109,13 @@ oc_exct_2() = Base.Experimental.@opaque Tuple{Number}->Number (x) -> '1'
@test Base.infer_exception_type((Int,)) do x
oc_exct_2()(x)
end == TypeError

# nothrow modeling for `invoke` calls
f_invoke_nothrow(::Number) = :number
f_invoke_nothrow(::Int) = :int
@test Base.infer_effects((Int,)) do x
@invoke f_invoke_nothrow(x::Number)
end |> Core.Compiler.is_nothrow
@test Base.infer_effects((Union{Nothing,Int},)) do x
@invoke f_invoke_nothrow(x::Number)
end |> !Core.Compiler.is_nothrow

0 comments on commit 6916bc1

Please sign in to comment.