Skip to content

Commit d77836e

Browse files
committed
add tests for REPL-completion through getindex(::Dict)
1 parent b193cc9 commit d77836e

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

stdlib/REPL/src/REPLCompletions.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,8 @@ struct REPLInterpreter <: CC.AbstractInterpreter
457457
code_cache::REPLInterpreterCache
458458
function REPLInterpreter(repl_frame::CC.InferenceResult;
459459
world::UInt = Base.get_world_counter(),
460-
inf_params::CC.InferenceParams = CC.InferenceParams(),
460+
inf_params::CC.InferenceParams = CC.InferenceParams(;
461+
unoptimize_throw_blocks=false),
461462
opt_params::CC.OptimizationParams = CC.OptimizationParams(),
462463
inf_cache::Vector{CC.InferenceResult} = CC.InferenceResult[],
463464
code_cache::REPLInterpreterCache = get_code_cache())

stdlib/REPL/test/replcompletions.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,6 +1842,24 @@ let s = "Ref(Issue36437(42))[]."
18421842
@test "v" c
18431843
end
18441844

1845+
# concrete evaluation throught `getindex`ing dictionary
1846+
global_dict = Dict{Symbol, Any}(:a => r"foo")
1847+
let s = "global_dict[:a]."
1848+
c, r, res = test_complete_context(s, @__MODULE__)
1849+
@test res
1850+
for fname in fieldnames(Regex)
1851+
@test String(fname) in c
1852+
end
1853+
end
1854+
global_dict_nested = Dict{Symbol, Any}(:a => global_dict)
1855+
let s = "global_dict_nested[:a][:a]."
1856+
c, r, res = test_complete_context(s, @__MODULE__)
1857+
@test res
1858+
for fname in fieldnames(Regex)
1859+
@test String(fname) in c
1860+
end
1861+
end
1862+
18451863
const global_xs = [Some(42)]
18461864
let s = "pop!(global_xs)."
18471865
c, r, res = test_complete_context(s, @__MODULE__)

test/dict.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,8 +1495,10 @@ end
14951495

14961496
# getindex is :effect_free and :terminates but not :consistent
14971497
for T in (Int, Float64, String, Symbol)
1498-
@test !Core.Compiler.is_consistent(Base.infer_effects(getindex, (Dict{T,Any}, T)))
1499-
@test Core.Compiler.is_effect_free(Base.infer_effects(getindex, (Dict{T,Any}, T)))
1500-
@test !Core.Compiler.is_nothrow(Base.infer_effects(getindex, (Dict{T,Any}, T)))
1501-
@test Core.Compiler.is_terminates(Base.infer_effects(getindex, (Dict{T,Any}, T)))
1498+
@testset let T=T
1499+
@test !Core.Compiler.is_consistent(Base.infer_effects(getindex, (Dict{T,Any}, T)))
1500+
@test_broken Core.Compiler.is_effect_free(Base.infer_effects(getindex, (Dict{T,Any}, T)))
1501+
@test !Core.Compiler.is_nothrow(Base.infer_effects(getindex, (Dict{T,Any}, T)))
1502+
@test_broken Core.Compiler.is_terminates(Base.infer_effects(getindex, (Dict{T,Any}, T)))
1503+
end
15021504
end

0 commit comments

Comments
 (0)