diff --git a/base/compiler/abstractinterpretation.jl b/base/compiler/abstractinterpretation.jl index 3701fa8cf9cae9..4d840b1fbdce69 100644 --- a/base/compiler/abstractinterpretation.jl +++ b/base/compiler/abstractinterpretation.jl @@ -2311,9 +2311,7 @@ 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) + e = e.value elseif isa(e, SSAValue) return RTEffects(abstract_eval_ssavalue(e, sv), Union{}, EFFECTS_TOTAL) elseif isa(e, SlotNumber) @@ -2335,8 +2333,9 @@ 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) + 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) diff --git a/test/compiler/effects.jl b/test/compiler/effects.jl index 2c303f53356339..71eb50cd427608 100644 --- a/test/compiler/effects.jl +++ b/test/compiler/effects.jl @@ -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{}))