Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
14 changes: 7 additions & 7 deletions base/compiler/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2310,11 +2310,7 @@ function abstract_eval_cfunction(interp::AbstractInterpreter, e::Expr, vtypes::U
end

function abstract_eval_special_value(interp::AbstractInterpreter, @nospecialize(e), vtypes::Union{VarTable,Nothing}, sv::AbsIntState)
if isa(e, QuoteNode)
effects = Effects(EFFECTS_TOTAL;
inaccessiblememonly = is_mutation_free_argtype(typeof(e.value)) ? ALWAYS_TRUE : ALWAYS_FALSE)
return RTEffects(Const(e.value), Union{}, effects)
elseif isa(e, SSAValue)
if isa(e, SSAValue)
return RTEffects(abstract_eval_ssavalue(e, sv), Union{}, EFFECTS_TOTAL)
elseif isa(e, SlotNumber)
if vtypes !== nothing
Expand All @@ -2335,8 +2331,12 @@ function abstract_eval_special_value(interp::AbstractInterpreter, @nospecialize(
elseif isa(e, GlobalRef)
return abstract_eval_globalref(interp, e, sv)
end

return RTEffects(Const(e), Union{}, EFFECTS_TOTAL)
if isa(e, QuoteNode)
e = e.value
end
effects = Effects(EFFECTS_TOTAL;
inaccessiblememonly = is_mutation_free_argtype(typeof(e)) ? ALWAYS_TRUE : ALWAYS_FALSE)
return RTEffects(Const(e), Union{}, effects)
end

function abstract_eval_value_expr(interp::AbstractInterpreter, e::Expr, sv::AbsIntState)
Expand Down
6 changes: 6 additions & 0 deletions test/compiler/effects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1370,6 +1370,12 @@ top_52531(_) = (set_initialized52531!(true); nothing)
top_52531(0)
@test is_initialized52531()

const ref52843 = Ref{Int}()
@eval func52843() = ($ref52843[] = 1; nothing)
@test !Core.Compiler.is_foldable(Base.infer_effects(func52843))
let; Base.Experimental.@force_compile; func52843(); end
@test ref52843[] == 1

@test Core.Compiler.is_inaccessiblememonly(Base.infer_effects(identity∘identity, Tuple{Any}))
@test Core.Compiler.is_inaccessiblememonly(Base.infer_effects(()->Vararg, Tuple{}))

Expand Down