@@ -503,6 +503,11 @@ function adjust_effects(sv::InferenceState)
503503 return ipo_effects
504504end
505505
506+ function refine_exception_type (@nospecialize (exc_bestguess), ipo_effects:: Effects )
507+ ipo_effects. nothrow && return Bottom
508+ return exc_bestguess
509+ end
510+
506511# inference completed on `me`
507512# update the MethodInstance
508513function finish (me:: InferenceState , interp:: AbstractInterpreter )
@@ -539,8 +544,8 @@ function finish(me::InferenceState, interp::AbstractInterpreter)
539544 end
540545 me. result. valid_worlds = me. valid_worlds
541546 me. result. result = bestguess
542- me. result. ipo_effects = me. ipo_effects = adjust_effects (me)
543- me. result. exc_result = exc_bestguess
547+ ipo_effects = me. result. ipo_effects = me. ipo_effects = adjust_effects (me)
548+ me. result. exc_result = me . exc_bestguess = refine_exception_type (me . exc_bestguess, ipo_effects)
544549
545550 if limited_ret
546551 # a parent may be cached still, but not this intermediate work:
@@ -862,20 +867,23 @@ function typeinf_edge(interp::AbstractInterpreter, method::Method, @nospecialize
862867 isinferred = is_inferred (frame)
863868 edge = isinferred ? mi : nothing
864869 effects = isinferred ? frame. result. ipo_effects : adjust_effects (Effects (), method) # effects are adjusted already within `finish` for ipo_effects
870+ exc_bestguess = refine_exception_type (frame. exc_bestguess, effects)
865871 # propagate newly inferred source to the inliner, allowing efficient inlining w/o deserialization:
866872 # note that this result is cached globally exclusively, we can use this local result destructively
867873 volatile_inf_result = isinferred && let inferred_src = result. src
868874 isa (inferred_src, CodeInfo) && (is_inlineable (inferred_src) || force_inline)
869875 end ? VolatileInferenceResult (result) : nothing
870- return EdgeCallResult (frame. bestguess, frame . exc_bestguess, edge, effects, volatile_inf_result)
876+ return EdgeCallResult (frame. bestguess, exc_bestguess, edge, effects, volatile_inf_result)
871877 elseif frame === true
872878 # unresolvable cycle
873879 return EdgeCallResult (Any, Any, nothing , Effects ())
874880 end
875881 # return the current knowledge about this cycle
876882 frame = frame:: InferenceState
877883 update_valid_age! (caller, frame. valid_worlds)
878- return EdgeCallResult (frame. bestguess, frame. exc_bestguess, nothing , adjust_effects (Effects (), method))
884+ effects = adjust_effects (Effects (), method)
885+ exc_bestguess = refine_exception_type (frame. exc_bestguess, effects)
886+ return EdgeCallResult (frame. bestguess, exc_bestguess, nothing , effects)
879887end
880888
881889function cached_return_type (code:: CodeInstance )
0 commit comments