-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Fix a JET warning #59111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix a JET warning #59111
Conversation
invalid builtin function call: getfield(x::RawFD, f::Symbol)
I'm ok with it, but also does point to missing inference quality in guarded generators. |
Yes I agree this is kinda papering over a problem (or opportunity for improvement). I am seeing more (all against the Julia
Yet the code in question seems like it should require no union splitting at all, at least in two of the tree places, since either a concrete type is checked, or a function maybe_spawn_cache_PATH()
global PATH_cache_task, next_cache_update
@lock PATH_cache_lock begin
PATH_cache_task isa Task && !istaskdone(PATH_cache_task) && return # <- JET warning 1
time() < next_cache_update && return
PATH_cache_task = Threads.@spawn begin
REPLCompletions.cache_PATH()
@lock PATH_cache_lock begin
next_cache_update = time() + 10 # earliest next update can run is 10s after
PATH_cache_task = nothing # release memory when done
PATH_cache_condition !== nothing && notify(PATH_cache_condition) # <- JET warning 2
end
end
Base.errormonitor(PATH_cache_task) # <- JET warning 3
end
end |
This addresses type inference issues with filtered list comprehensions reported in #59111. The root cause is the compiler's inability to perform type refinement in cases like: ```julia let t::Tuple{Any,Any} x, y = t if x isa Int return t # still `::Tuple{Any,Any}` end nothing end ``` Fixing this fundamentally would require extensive improvements to abstract interpretation. As a workaround, I improved the iterators.jl implementation to avoid this pattern. One implementation consideration: if `iterate(f.itr, state...)` always returns `Union{Nothing,Tuple{Any,Any}}`, the `if y isa Tuple{Any,Any}` branch should be unnecessary. However, it's unclear whether we can safely assume this for the iterate interface, so I kept the branch for now.
Will be fixed by #59142. |
This addresses type inference issues with filtered list comprehensions reported in #59111. The root cause is the compiler's inability to perform type refinement in cases like: ```julia let t::Tuple{Any,Any} x, y = t if x isa Int return t # still `::Tuple{Any,Any}` end nothing end ``` Fixing this fundamentally would require extensive improvements to abstract interpretation. As a workaround, I improved the iterators.jl implementation to avoid this pattern. One implementation consideration: if `iterate(f.itr, state...)` always returns `Union{Nothing,Tuple{Any,Any}}`, the `if y isa Tuple{Any,Any}` branch should be unnecessary. However, it's unclear whether we can safely assume this for the iterate interface, so I kept the branch for now.
This addresses type inference issues with filtered list comprehensions reported in #59111. The root cause is the compiler's inability to perform type refinement in cases like: ```julia let t::Tuple{Any,Any} x, y = t if x isa Int return t # still `::Tuple{Any,Any}` end nothing end ``` Fixing this fundamentally would require extensive improvements to abstract interpretation. As a workaround, I improved the iterators.jl implementation to avoid this pattern. One implementation consideration: if `iterate(f.itr, state...)` always returns `Union{Nothing,Tuple{Any,Any}}`, the `if y isa Tuple{Any,Any}` branch should be unnecessary. However, it's unclear whether we can safely assume this for the iterate interface, so I kept the branch for now.
With these linked PRs merged, now I think this PR can be closed. |
Backported. |
Encountered while looking through JET report for GAP.jl
Clearly the code itself really is fine, but the annotation silences this warning.
Full context: