Inconsistent results when using Threads.@threads in a loop

It feels like the same realm as not being able to conditionally define methods for functions in local scopes, every method just exists at once. Issue 15602 states that dynamically creating functions is too slow and this allows functions to be hoisted to top-level (like a functor). That rationale wouldn’t apply to local variable existence, and I’m guessing lowering could be changed to differentiate the latter v_re and v_im without performance penalty, but both seem rooted in how the local scope is built during compilation. Another unintuitive implementation is how global variables act like references rather than values in function inputs.

Example of conditional methods not working in a local scope
julia> foofalse = let
         foo() = 0
         if false  foo(x) = 1  end
         foo
       end
(::var"#foo#1") (generic function with 2 methods)

julia> foo() = 0
foo (generic function with 1 method)

julia> if false  foo(x) = 1  end

julia> foo
foo (generic function with 1 method)

julia> if true  foo(x) = 1  end
foo (generic function with 2 methods)