Skip to content

Commit 0fdd55b

Browse files
authored
Fix inconsistency between exct and nothrow effect (#52853)
Fixes #52846. Different unreachability checks use different definitions for this and were inconsistenct, causing the assertion. Since the exct modeling isn't fully plubmed through all corners of the compiler yet, also change the caller code to force the nothrow effect to be authoritative for the time being.
1 parent cf44b53 commit 0fdd55b

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,8 +2119,14 @@ function abstract_call_known(interp::AbstractInterpreter, @nospecialize(f),
21192119
abstract_call_gf_by_type(interp, f, ArgInfo(nothing, T), si, atype, sv, max_methods)
21202120
end
21212121
pT = typevar_tfunc(𝕃ᵢ, n, lb_var, ub_var)
2122-
effects = builtin_effects(𝕃ᵢ, Core._typevar, Any[n, lb_var, ub_var], pT)
2123-
return CallMeta(pT, Any, effects, call.info)
2122+
typevar_argtypes = Any[n, lb_var, ub_var]
2123+
effects = builtin_effects(𝕃ᵢ, Core._typevar, typevar_argtypes, pT)
2124+
if effects.nothrow
2125+
exct = Union{}
2126+
else
2127+
exct = builtin_exct(𝕃ᵢ, Core._typevar, typevar_argtypes, pT)
2128+
end
2129+
return CallMeta(pT, exct, effects, call.info)
21242130
elseif f === UnionAll
21252131
call = abstract_call_gf_by_type(interp, f, ArgInfo(nothing, Any[Const(UnionAll), Any, Any]), si, Tuple{Type{UnionAll}, Any, Any}, sv, max_methods)
21262132
return abstract_call_unionall(interp, argtypes, call)
@@ -3288,10 +3294,12 @@ function typeinf_local(interp::AbstractInterpreter, frame::InferenceState)
32883294
# Process non control-flow statements
32893295
(; changes, rt, exct) = abstract_eval_basic_statement(interp,
32903296
stmt, currstate, frame)
3291-
if exct !== Union{}
3292-
update_exc_bestguess!(interp, exct, frame)
3293-
end
32943297
if !has_curr_ssaflag(frame, IR_FLAG_NOTHROW)
3298+
if exct !== Union{}
3299+
update_exc_bestguess!(interp, exct, frame)
3300+
# TODO: assert that these conditions match. For now, we assume the `nothrow` flag
3301+
# to be correct, but allow the exct to be an over-approximation.
3302+
end
32953303
propagate_to_error_handler!(currstate, frame, 𝕃ᵢ)
32963304
end
32973305
if rt === Bottom

0 commit comments

Comments
 (0)