Skip to content

@compile_workload should run after any export statements #3811

@topolarity

Description

@topolarity

This is because of patterns like this:

module PackageModule
struct Foo end

module InnerModule
using ..PackageModule
foo() = cond() ? (x isa Foo) : nothing
end

Inner.foo() # when inferring foo(), Foo has no binding it can be resolved to
export Foo  # by exporting, Foo inside foo() suddenly resolves to a binding, so the code is invalidated

end

Essentially, an inner module has an implicit import (using ..PackageModule) which picks up an outer type Foo, but only after the export Foo is executed at the outer level.

The meaning of Foo changes once export Foo is executed, causing invalidation. As a concrete example, this kind of thing happens in practice for StructuralTransformations._distribute_shift and export Pre when pre-compiling current master MTK.

That's an easy bug to fix, and has a very small impact on latency anyway, but I wanted to open the issue for awareness.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions