-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
fix invalidations of isinf
from Static.jl
#46493
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
Conversation
While it is documented to return a julia> isnan(missing)
missing in Base. We could assert it is julia> isequal(missing, missing)
true
julia> isequal(missing, 'a')
false but it's a little less safe here. |
But we have julia> missing isa Real
false so julia> @which isinf(missing)
isinf(::Missing) in Base at missing.jl:101 does not use the method I changed here. |
I also checked ForwardDiff.jl, which has julia> using ForwardDiff
julia> x = ForwardDiff.Dual{Float64}(1.0, (0.0, 0.0))
Dual{Float64}(1.0,0.0,0.0)
julia> x isa Real
true They implement their own logic for julia> @which isinf(x)
isinf(d::ForwardDiff.Dual) in ForwardDiff at ~/.julia/packages/ForwardDiff/pDtsf/src/dual.jl:384
julia> @which isnan(x)
isnan(d::ForwardDiff.Dual) in ForwardDiff at ~/.julia/packages/ForwardDiff/pDtsf/src/dual.jl:384
julia> @which isfinite(x)
isfinite(d::ForwardDiff.Dual) in ForwardDiff at ~/.julia/packages/ForwardDiff/pDtsf/src/dual.jl:384 |
But I think you are right, this may be not a good approach to fix the invalidations. There could be other packages implementing their own special return types, e.g., some SIMD types. I will look into this later. |
I was able to fix the invalidations one level higher. As far as I can tell, this should be save since it is
I suggest the labels |
(cherry picked from commit c2a1650)
This should hopefully fix quite some invalidations coming from Static.jl.
Here is the code:
Since
isnan
andisfinite
are documented to returnBool
s, it appears to be sane to assert that they do here.