Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inference: simplify error-case handling within abstract_eval_statement #46119

Merged
merged 2 commits into from
Jul 21, 2022
Merged
Changes from 1 commit
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
17 changes: 7 additions & 10 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1968,7 +1968,7 @@ function abstract_eval_statement(interp::AbstractInterpreter, @nospecialize(e),
ismutable = ismutabletype(t)
fcount = fieldcount(t)
nargs = length(e.args) - 1
is_nothrow && (is_nothrow = fcount ≥ nargs)
@assert fcount ≥ nargs # syntactically enforced by the front-end
ats = Vector{Any}(undef, nargs)
local anyrefine = false
local allconst = true
Expand All @@ -1977,11 +1977,7 @@ function abstract_eval_statement(interp::AbstractInterpreter, @nospecialize(e),
ft = fieldtype(t, i)
is_nothrow && (is_nothrow = at ⊑ ft)
at = tmeet(at, ft)
if at === Bottom
t = Bottom
tristate_merge!(sv, EFFECTS_THROWS)
@goto t_computed
end
at === Bottom && @goto always_throw
if ismutable && !isconst(t, i)
ats[i] = ft # can't constrain this field (as it may be modified later)
continue
Expand Down Expand Up @@ -2060,9 +2056,7 @@ function abstract_eval_statement(interp::AbstractInterpreter, @nospecialize(e),
t = sp_type_rewrap(e.args[2], sv.linfo, true)
for i = 3:length(e.args)
if abstract_eval_value(interp, e.args[i], vtypes, sv) === Bottom
t = Bottom
tristate_merge!(sv, EFFECTS_THROWS)
@goto t_computed
@goto always_throw
end
end
effects = EFFECTS_UNKNOWN
Expand Down Expand Up @@ -2122,10 +2116,13 @@ function abstract_eval_statement(interp::AbstractInterpreter, @nospecialize(e),
end
end
end
elseif false
@label always_throw
t = Bottom
tristate_merge!(sv, EFFECTS_THROWS)
else
t = abstract_eval_value_expr(interp, e, vtypes, sv)
end
@label t_computed
@assert !isa(t, TypeVar) "unhandled TypeVar"
if isa(t, DataType) && isdefined(t, :instance)
# replace singleton types with their equivalent Const object
Expand Down