Skip to content

invoked signatures spuriously invalidate in precompilation #44320

@timholy

Description

@timholy

(This is copied over from #43990 (comment))

When a method is called via invoke, the specialization might appear to be one that should be superseded, but this is not always the case. To demonstrate this, create two packages:

module PkgA

f(::Int) = 1
f(::Any) = 2

g() = invoke(f, Tuple{Any}, 0)

g()

end # module

and

module PkgB

using PkgA

PkgA.f(::Real) = 3

end # module

We incorrectly invalidate g when we load PkgB:

julia> using PkgA

julia> PkgA.g()
2

julia> m = which(PkgA.g, ())
g() in PkgA at /tmp/pkgv/PkgA/src/PkgA.jl:6

julia> mi = m.specializations[1]
MethodInstance for PkgA.g()

julia> mi.cache.max_world
0xffffffffffffffff

julia> using PkgB

julia> mi.cache.max_world
0x0000000000007a61

julia> PkgA.g()
2

This is incorrect because the code that should run is unchanged by loading PkgB.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions