Skip to content

Commit 6916bc1

Browse files
committed
fix nothrow modeling for invoke calls
1 parent 7a65218 commit 6916bc1

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

base/compiler/abstractinterpretation.jl

+3
Original file line numberDiff line numberDiff line change
@@ -2181,6 +2181,9 @@ function abstract_invoke(interp::AbstractInterpreter, arginfo::ArgInfo, si::Stmt
21812181
rt = from_interprocedural!(interp, rt, sv, arginfo, sig)
21822182
info = InvokeCallInfo(match, const_result)
21832183
edge !== nothing && add_invoke_backedge!(sv, lookupsig, edge)
2184+
if !match.fully_covers
2185+
effects = Effects(effects; nothrow=false)
2186+
end
21842187
return CallMeta(rt, Any, effects, info)
21852188
end
21862189

test/compiler/inference.jl

+10
Original file line numberDiff line numberDiff line change
@@ -6109,3 +6109,13 @@ oc_exct_2() = Base.Experimental.@opaque Tuple{Number}->Number (x) -> '1'
61096109
@test Base.infer_exception_type((Int,)) do x
61106110
oc_exct_2()(x)
61116111
end == TypeError
6112+
6113+
# nothrow modeling for `invoke` calls
6114+
f_invoke_nothrow(::Number) = :number
6115+
f_invoke_nothrow(::Int) = :int
6116+
@test Base.infer_effects((Int,)) do x
6117+
@invoke f_invoke_nothrow(x::Number)
6118+
end |> Core.Compiler.is_nothrow
6119+
@test Base.infer_effects((Union{Nothing,Int},)) do x
6120+
@invoke f_invoke_nothrow(x::Number)
6121+
end |> !Core.Compiler.is_nothrow

0 commit comments

Comments
 (0)