diff --git a/base/dict.jl b/base/dict.jl index 6a316bee5aef3..eaee28271d6d5 100644 --- a/base/dict.jl +++ b/base/dict.jl @@ -271,7 +271,7 @@ function empty!(h::Dict{K,V}) where V where K end # get the index where a key is stored, or -1 if not present -@assume_effects :terminates_locally function ht_keyindex(h::Dict{K,V}, key) where V where K +function ht_keyindex(h::Dict{K,V}, key) where V where K isempty(h) && return -1 sz = length(h.keys) iter = 0 @@ -280,9 +280,9 @@ end index, sh = hashindex(key, sz) keys = h.keys - @inbounds while true + @assume_effects :terminates_locally :noub @inbounds while true isslotempty(h,index) && return -1 - if h.slots[index] == sh + if sh == h.slots[index] k = keys[index] if (key === k || isequal(key, k)) return index @@ -294,8 +294,6 @@ end end # This line is unreachable end -@assume_effects :noub ht_keyindex(h::Dict{Symbol,V}, key::Symbol) where V = - @invoke ht_keyindex(h::Dict{Symbol,V}, key::Any) # get (index, sh) for the key # index - where a key is stored, or -pos if not present @@ -509,10 +507,8 @@ end function getindex(h::Dict{K,V}, key) where V where K index = ht_keyindex(h, key) - @inbounds return (index < 0) ? throw(KeyError(key)) : h.vals[index]::V + return index < 0 ? throw(KeyError(key)) : @assume_effects :noub @inbounds h.vals[index]::V end -@assume_effects :noub getindex(h::Dict{Symbol,V}, key::Symbol) where V = - @invoke getindex(h::Dict{Symbol,V}, key::Any) """ get(collection, key, default) diff --git a/stdlib/REPL/test/replcompletions.jl b/stdlib/REPL/test/replcompletions.jl index ed5ebd417eb4c..05064e7b7e063 100644 --- a/stdlib/REPL/test/replcompletions.jl +++ b/stdlib/REPL/test/replcompletions.jl @@ -2165,12 +2165,12 @@ for (DictT, KeyT) = Any[(Dict{Symbol,Any}, Symbol), effects = Base.infer_effects(getindex, (DictT,KeyT); interp=REPL.REPLCompletions.REPLInterpreter()) @test Core.Compiler.is_effect_free(effects) @test Core.Compiler.is_terminates(effects) - @test Core.Compiler.is_noub(effects) broken=(KeyT!==Symbol) + @test Core.Compiler.is_noub(effects) effects = Base.infer_effects((DictT,KeyT); interp=REPL.REPLCompletions.REPLInterpreter()) do d, key key in keys(d) end @test Core.Compiler.is_effect_free(effects) @test Core.Compiler.is_terminates(effects) - @test Core.Compiler.is_noub(effects) broken=(KeyT!==Symbol) + @test Core.Compiler.is_noub(effects) end end