Skip to content

Commit 9473ef7

Browse files
authored
inference: avoid LimitedAccuracy within slot wrappers (#59182)
I looked at all the usage sites of these constructors within the compiler, and fortunately it appears that none of the usage sites require that the return values of these constructors be objects of their respective types. So in cases where `LimitedAccuracy` is given as a wrapped element, these slot type refinements simply will not be performed. - fixes #59004
1 parent 7cbea5f commit 9473ef7

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Compiler/src/abstractinterpretation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3255,7 +3255,7 @@ function abstract_eval_copyast(interp::AbstractInterpreter, e::Expr, sstate::Sta
32553255
return RTEffects(rt, Any, effects)
32563256
end
32573257

3258-
function abstract_eval_isdefined_expr(interp::AbstractInterpreter, e::Expr, sstate::StatementState,
3258+
function abstract_eval_isdefined_expr(::AbstractInterpreter, e::Expr, sstate::StatementState,
32593259
sv::AbsIntState)
32603260
sym = e.args[1]
32613261
if isa(sym, SlotNumber) && sstate.vtypes !== nothing

Compiler/src/typelattice.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ struct Conditional
4040
isdefined::Bool=false)
4141
assert_nested_slotwrapper(thentype)
4242
assert_nested_slotwrapper(elsetype)
43+
if thentype isa LimitedAccuracy || elsetype isa LimitedAccuracy
44+
return Bool
45+
end
4346
return new(slot, thentype, elsetype, isdefined)
4447
end
4548
end
@@ -83,6 +86,9 @@ struct MustAlias
8386
assert_nested_slotwrapper(fldtyp)
8487
# @assert !isalreadyconst(vartyp) "vartyp is already const"
8588
# @assert !isalreadyconst(fldtyp) "fldtyp is already const"
89+
if vartyp isa LimitedAccuracy || fldtyp isa LimitedAccuracy
90+
return fldtyp
91+
end
8692
return new(slot, vartyp, fldidx, fldtyp)
8793
end
8894
end
@@ -104,6 +110,9 @@ struct InterMustAlias
104110
assert_nested_slotwrapper(fldtyp)
105111
# @assert !isalreadyconst(vartyp) "vartyp is already const"
106112
# @assert !isalreadyconst(fldtyp) "fldtyp is already const"
113+
if vartyp isa LimitedAccuracy || fldtyp isa LimitedAccuracy
114+
return fldtyp
115+
end
107116
return new(slot, vartyp, fldidx, fldtyp)
108117
end
109118
end

0 commit comments

Comments
 (0)