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
12 changes: 10 additions & 2 deletions Compiler/src/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3240,8 +3240,16 @@ function abstract_eval_throw_undef_if_not(interp::AbstractInterpreter, e::Expr,
end

function abstract_eval_the_exception(::AbstractInterpreter, sv::InferenceState)
(;handlers, handler_at) = sv.handler_info::HandlerInfo
return the_exception_info(handlers[handler_at[sv.currpc][2]].exct)
(;handler_info) = sv
if handler_info === nothing
return the_exception_info(Any)
end
(;handlers, handler_at) = handler_info
handler_id = handler_at[sv.currpc][2]
if handler_id === 0
return the_exception_info(Any)
end
return the_exception_info(handlers[handler_id].exct)
end
abstract_eval_the_exception(::AbstractInterpreter, ::IRInterpretationState) = the_exception_info(Any)
the_exception_info(@nospecialize t) = RTEffects(t, Union{}, Effects(EFFECTS_TOTAL; consistent=ALWAYS_FALSE))
Expand Down
14 changes: 14 additions & 0 deletions Compiler/test/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6125,3 +6125,17 @@ function func_swapglobal!_must_throw(x)
end
@test Base.infer_return_type(func_swapglobal!_must_throw, (Int,); interp=SwapGlobalInterp()) === Union{}
@test !Compiler.is_effect_free(Base.infer_effects(func_swapglobal!_must_throw, (Int,); interp=SwapGlobalInterp()) )

@eval get_exception() = $(Expr(:the_exception))
@test Base.infer_return_type() do
get_exception()
end <: Any
@test @eval Base.infer_return_type((Float64,)) do x
out = $(Expr(:the_exception))
try
out = sin(x)
catch
out = $(Expr(:the_exception))
end
return out
end == Union{Float64,DomainError}
Loading