Skip to content

Some rebindings don't propagate through exportsΒ #59272

@timholy

Description

@timholy

This is a Revise-independent reproducer of timholy/Revise.jl#894 (comment)

With Foo.jl defined as

module Foo
export Bar

struct Bar
    # x
end
end

we find

tim@kenzo:/tmp/rvs$ julia +nightly --startup-file=no
A new `nightly` version is available. Install with `juliaup update`.
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.13.0-DEV.974 (2025-08-12)
 _/ |\__'_|_|_|\__'_|  |  Commit 7bbb213719b (1 day old master)
|__/                   |

julia> Revise     # show that this is independent of Revise
ERROR: UndefVarError: `Revise` not defined in `Main`
Suggestion: check for spelling errors or missing imports.

julia> include("Foo.jl")
Main.Foo

julia> using .Foo

julia> Bar()
Bar()

julia> Core.eval(Foo, :(struct Bar; x; end))

julia> Foo.Bar(1)
Main.Foo.Bar(1)

julia> Bar(1)
ERROR: MethodError: no method matching @world(Main.Foo.Bar, 39018:39020)(::Int64)
The type `@world(Main.Foo.Bar, 39018:39020)` exists, but no method is defined for this combination of argument types when trying to construct it.

Closest candidates are:
  @world(Main.Foo.Bar, 39018:39020)()
   @ Main.Foo /tmp/rvs/Foo.jl:4

Stacktrace:
 [1] top-level scope
   @ REPL[7]:1

julia> using .Foo: Bar

julia> Bar(1)
Bar(1)

The same behavior is observed if you instead import Foo via

push!(LOAD_PATH, ".")
using Foo

It's not 100% clear to me that this is a bug. But since we have rebinding tests that enforce the fact that deletion events do propagate across exports:

julia/test/rebinding.jl

Lines 86 to 91 in 9c94e7a

# + via using
using .DeleteMeModule
f_return_delete_me_implicit() = delete_me_implicit
@test f_return_delete_me_implicit() == 6
Base.delete_binding(DeleteMeModule, :delete_me_implicit)
@test_throws UndefVarError f_return_delete_me_implicit()

to me it seems like a bug that rebindings do not.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions