Skip to content

Commit

Permalink
inference: simplify error-case handling within `abstract_eval_stateme…
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk authored and Francesco Fucci committed Aug 11, 2022
1 parent f9fc9f9 commit 808bbef
Showing 1 changed file with 7 additions and 10 deletions.
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 "malformed :new expression" # 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

0 comments on commit 808bbef

Please sign in to comment.