Skip to content

Commit

Permalink
add tests for REPL-completion through getindex(::Dict)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk committed Sep 26, 2023
1 parent b193cc9 commit d77836e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
3 changes: 2 additions & 1 deletion stdlib/REPL/src/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,8 @@ struct REPLInterpreter <: CC.AbstractInterpreter
code_cache::REPLInterpreterCache
function REPLInterpreter(repl_frame::CC.InferenceResult;
world::UInt = Base.get_world_counter(),
inf_params::CC.InferenceParams = CC.InferenceParams(),
inf_params::CC.InferenceParams = CC.InferenceParams(;
unoptimize_throw_blocks=false),
opt_params::CC.OptimizationParams = CC.OptimizationParams(),
inf_cache::Vector{CC.InferenceResult} = CC.InferenceResult[],
code_cache::REPLInterpreterCache = get_code_cache())
Expand Down
18 changes: 18 additions & 0 deletions stdlib/REPL/test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1842,6 +1842,24 @@ let s = "Ref(Issue36437(42))[]."
@test "v" c
end

# concrete evaluation throught `getindex`ing dictionary
global_dict = Dict{Symbol, Any}(:a => r"foo")
let s = "global_dict[:a]."
c, r, res = test_complete_context(s, @__MODULE__)
@test res
for fname in fieldnames(Regex)
@test String(fname) in c
end
end
global_dict_nested = Dict{Symbol, Any}(:a => global_dict)
let s = "global_dict_nested[:a][:a]."
c, r, res = test_complete_context(s, @__MODULE__)
@test res
for fname in fieldnames(Regex)
@test String(fname) in c
end
end

const global_xs = [Some(42)]
let s = "pop!(global_xs)."
c, r, res = test_complete_context(s, @__MODULE__)
Expand Down
10 changes: 6 additions & 4 deletions test/dict.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1495,8 +1495,10 @@ end

# getindex is :effect_free and :terminates but not :consistent
for T in (Int, Float64, String, Symbol)
@test !Core.Compiler.is_consistent(Base.infer_effects(getindex, (Dict{T,Any}, T)))
@test Core.Compiler.is_effect_free(Base.infer_effects(getindex, (Dict{T,Any}, T)))
@test !Core.Compiler.is_nothrow(Base.infer_effects(getindex, (Dict{T,Any}, T)))
@test Core.Compiler.is_terminates(Base.infer_effects(getindex, (Dict{T,Any}, T)))
@testset let T=T
@test !Core.Compiler.is_consistent(Base.infer_effects(getindex, (Dict{T,Any}, T)))
@test_broken Core.Compiler.is_effect_free(Base.infer_effects(getindex, (Dict{T,Any}, T)))
@test !Core.Compiler.is_nothrow(Base.infer_effects(getindex, (Dict{T,Any}, T)))
@test_broken Core.Compiler.is_terminates(Base.infer_effects(getindex, (Dict{T,Any}, T)))
end
end

0 comments on commit d77836e

Please sign in to comment.