Skip to content

Commit fd13cf0

Browse files
committed
effects: fix #52843, account for mutable values directly embedded to IR
Fixes another variant of #52531.
1 parent 5c0a2a6 commit fd13cf0

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2267,11 +2267,7 @@ function abstract_eval_value_expr(interp::AbstractInterpreter, e::Expr, vtypes::
22672267
end
22682268

22692269
function abstract_eval_special_value(interp::AbstractInterpreter, @nospecialize(e), vtypes::Union{VarTable,Nothing}, sv::AbsIntState)
2270-
if isa(e, QuoteNode)
2271-
merge_effects!(interp, sv, Effects(EFFECTS_TOTAL;
2272-
inaccessiblememonly = is_mutation_free_argtype(typeof(e.value)) ? ALWAYS_TRUE : ALWAYS_FALSE))
2273-
return Const(e.value)
2274-
elseif isa(e, SSAValue)
2270+
if isa(e, SSAValue)
22752271
return abstract_eval_ssavalue(e, sv)
22762272
elseif isa(e, SlotNumber)
22772273
if vtypes !== nothing
@@ -2293,7 +2289,11 @@ function abstract_eval_special_value(interp::AbstractInterpreter, @nospecialize(
22932289
elseif isa(e, GlobalRef)
22942290
return abstract_eval_globalref(interp, e, sv)
22952291
end
2296-
2292+
if isa(e, QuoteNode)
2293+
e = e.value
2294+
end
2295+
merge_effects!(interp, sv, Effects(EFFECTS_TOTAL;
2296+
inaccessiblememonly = is_mutation_free_argtype(typeof(e)) ? ALWAYS_TRUE : ALWAYS_FALSE))
22972297
return Const(e)
22982298
end
22992299

test/compiler/effects.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,3 +1052,9 @@ top_52531(_) = (set_initialized52531!(true); nothing)
10521052
@test !is_initialized52531()
10531053
top_52531(0)
10541054
@test is_initialized52531()
1055+
1056+
const ref52843 = Ref{Int}()
1057+
@eval func52843() = ($ref52843[] = 1; nothing)
1058+
@test !Core.Compiler.is_foldable(Base.infer_effects(func52843))
1059+
let; Base.Experimental.@force_compile; func52843(); end
1060+
@test ref52843[] == 1

0 commit comments

Comments
 (0)