diff --git a/base/compiler/abstractinterpretation.jl b/base/compiler/abstractinterpretation.jl index 3701fa8cf9cae..5c27edea6d686 100644 --- a/base/compiler/abstractinterpretation.jl +++ b/base/compiler/abstractinterpretation.jl @@ -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 @@ -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) diff --git a/test/compiler/effects.jl b/test/compiler/effects.jl index 2c303f5335633..71eb50cd42760 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{}))