@@ -334,19 +334,23 @@ PATH_cache_task::Union{Task,Nothing} = nothing
334334PATH_cache_condition:: Union{Threads.Condition, Nothing}  =  nothing  #  used for sync in tests
335335next_cache_update:: Float64  =  0.0 
336336function  maybe_spawn_cache_PATH ()
337-     global  PATH_cache_task, next_cache_update
337+     global  PATH_cache_task, PATH_cache_condition, next_cache_update
338+     #  Extract to local variables to enable flow-sensitive type inference for these global variables
339+     PATH_cache_task_local =  PATH_cache_task
340+     PATH_cache_condition_local =  PATH_cache_condition
338341    @lock  PATH_cache_lock begin 
339-         PATH_cache_task  isa  Task &&  ! istaskdone (PATH_cache_task ) &&  return 
342+         PATH_cache_task_local  isa  Task &&  ! istaskdone (PATH_cache_task_local ) &&  return 
340343        time () <  next_cache_update &&  return 
341344        PATH_cache_task =  Threads. @spawn  begin 
342345            REPLCompletions. cache_PATH ()
343346            @lock  PATH_cache_lock begin 
344347                next_cache_update =  time () +  10  #  earliest next update can run is 10s after
345348                PATH_cache_task =  nothing  #  release memory when done
346-                 PATH_cache_condition  != =  nothing  &&  notify (PATH_cache_condition )
349+                 PATH_cache_condition_local  != =  nothing  &&  notify (PATH_cache_condition_local )
347350            end 
348351        end 
349-         Base. errormonitor (PATH_cache_task)
352+         PATH_cache_task_local =  PATH_cache_task
353+         Base. errormonitor (PATH_cache_task_local)
350354    end 
351355end 
352356
0 commit comments