Skip to content

Commit 14677ae

Browse files
ranochaKristofferC
authored andcommitted
fix invalidations related to ismutable (#52170)
Related to #52134. It would be nice if the underlying inference issue was fixed but this seems to be a hotfix for now. I have seen this inference problem occurring in Julia v1.9, v1.10, and current `master`. For example, on Julia v1.9.3, I get ```julia julia> code_warntype(ismutable, (Function,)) MethodInstance for ismutable(::Function) from ismutable(x) @ Base reflection.jl:521 Arguments #self#::Core.Const(ismutable) x::Function Body::Any 1 ─ nothing │ nothing │ %3 = Base.typeof(x)::Type{<:Function} │ %4 = Base.getproperty(%3, :name)::Any │ %5 = Base.getproperty(%4, :flags)::Any │ %6 = (%5 & 0x02)::Any │ %7 = (%6 == 0x02)::Any └── return %7 ``` This causes some invalidations when `using OrdinaryDiffEq`. (cherry picked from commit df40bab)
1 parent dbb9c46 commit 14677ae

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

base/reflection.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,9 @@ true
514514
!!! compat "Julia 1.5"
515515
This function requires at least Julia 1.5.
516516
"""
517-
ismutable(@nospecialize(x)) = (@_total_meta; typeof(x).name.flags & 0x2 == 0x2)
517+
ismutable(@nospecialize(x)) = (@_total_meta; (typeof(x).name::Core.TypeName).flags & 0x2 == 0x2)
518+
# The type assertion above is required to fix some invalidations.
519+
# See also https://github.com/JuliaLang/julia/issues/52134
518520

519521
"""
520522
ismutabletype(T) -> Bool

0 commit comments

Comments
 (0)