Skip to content
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

Spurrious "invalid redefinition of constant" error on types with self referential parameters in subtype delcaration #883

Open
LilithHafner opened this issue Jan 13, 2025 · 0 comments

Comments

@LilithHafner
Copy link
Contributor

Reproducer on [email protected], [email protected]

julia> using Pkg, Revise

julia> Pkg.generate("DemonstrationPackage")
  Generating  project DemonstrationPackage:
    DemonstrationPackage/Project.toml
    DemonstrationPackage/src/DemonstrationPackage.jl
Dict{String, Base.UUID} with 1 entry:
  "DemonstrationPackage" => UUID("59767476-78e9-4613-8abe-91176a478dbc")

(@v1.11) pkg> activate DemonstrationPackage/
  Activating project at `~/.julia/dev/DemonstrationPackage`

julia> open("DemonstrationPackage/src/DemonstrationPackage.jl", "w") do io
           print(io, """
           module DemonstrationPackage
           
           struct NestedDict{K, V} <: AbstractDict{K, Union{V, NestedDict}} end

           end
           """)
       end

julia> using DemonstrationPackage
[ Info: Precompiling DemonstrationPackage [59767476-78e9-4613-8abe-91176a478dbc] 

julia> open("DemonstrationPackage/src/DemonstrationPackage.jl", "a") do io
           println(io, "# Comment")
       end

julia> 1+1
┌ Error: Failed to revise /home/x/.julia/dev/DemonstrationPackage/src/DemonstrationPackage.jl
│   exception =
│    invalid redefinition of constant DemonstrationPackage.NestedDict
│    Stacktrace:
│     [1] top-level scope
│       @ ~/.julia/dev/DemonstrationPackage/src/DemonstrationPackage.jl:3
│    Revise evaluation error at /home/x/.julia/dev/DemonstrationPackage/src/DemonstrationPackage.jl:3
│    
└ @ Revise ~/.julia/packages/Revise/CawM1/src/packagedef.jl:776
┌ Warning: The running code does not match the saved version for the following files:
│ 
│   /home/x/.julia/dev/DemonstrationPackage/src/DemonstrationPackage.jl
│ 
│ If the error was due to evaluation order, it can sometimes be resolved by calling `Revise.retry()`.
│ Use Revise.errors() to report errors again. Only the first error in each file is shown.
│ Your prompt color may be yellow until the errors are resolved.
└ @ Revise ~/.julia/packages/Revise/CawM1/src/packagedef.jl:893
2

shell> cat DemonstrationPackage/src/DemonstrationPackage.jl
module DemonstrationPackage

struct NestedDict{K, V} <: AbstractDict{K, Union{V, NestedDict}} end

end
# Comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant