Upon further investigation, it appears that modifying this single line is enough to remove the call to the dead PersistentDict constructor. But, this seems to stem from an inference bug, where we're deleting statements without actually proving terminates.
julia> @noinline Base.@assume_effects :effect_free :nothrow function foo(n)
s = 0
while true
if n - rand(1:10) > 0
s += 1
else
break
end
end
return s
end^C
julia> code_typed((Int,)) do n
foo(n)
nothing
end
1-element Vector{Any}:
CodeInfo(
1 ─ return Main.nothing
) => Nothing
So, I'd like to address this bug first and then revisit this PR.
Originally posted by @aviatesk in #52954 (comment)