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

Wrong "Invalid redefinition of type" for certain UnionAll field types #770

Closed
stev47 opened this issue Oct 26, 2023 · 5 comments · Fixed by JuliaLang/julia#52748
Closed
Labels
bug juliabug Bug is due to a julia bug

Comments

@stev47
Copy link

stev47 commented Oct 26, 2023

Minimal example:

using Revise

mktemp() do f, io
    write(io, """
        struct A{T} end
        struct B{T, S}
          a::A{<:T}
        end
        """)
    close(io)
    includet(f)
end

results in

ERROR: LoadError: invalid redefinition of type B

The above works (try in fresh session) if either:

  • A{<:T} is replaced with A{T},
  • S is removed, or
  • includet replaced by standard include

This breaks normal Revise workflow even if no types are changed at all.
#734 possibly related.

@aviatesk
Copy link
Collaborator

The above example seems to work on the latest master and v1.10-beta3 with Revise v3.5.7. What is your Julia version and Revise version?

@stev47
Copy link
Author

stev47 commented Oct 26, 2023

The above example seems to work on the latest master and v1.10-beta3 with Revise v3.5.7. What is your Julia version and Revise version?

julia> versioninfo()
Julia Version 1.9.3
Commit bed2cd540a1 (2023-08-24 14:43 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 16 × AMD Ryzen 7 5825U with Radeon Graphics
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-14.0.6 (ORCJIT, znver3)
  Threads: 1 on 16 virtual cores
Environment:
  JULIA_PKG_USE_CLI_GIT = 1

(@v1.9) pkg> status Revise
Status `~/.julia/environments/v1.9/Project.toml`
  [295af30f] Revise v3.5.7

I did not try yet on v1.10 or master

@stev47
Copy link
Author

stev47 commented Oct 26, 2023

The above example seems to work on the latest master and v1.10-beta3 with Revise v3.5.7. What is your Julia version and Revise version?

I managed to reproduce both on Julia 1.10.0-beta3 and current master (1.11.0-DEV.745), each with Revise v3.5.7.

@thofma
Copy link

thofma commented Nov 8, 2023

Might be a dup of #753?

@timholy timholy added the bug label Dec 31, 2023
@timholy
Copy link
Owner

timholy commented Dec 31, 2023

Thanks for the MWE!

Bad news: this may be a Julia bug. (Revise just exploits the standard Julia functionality here.) includet effectively re-evaluates the file, skipping over anything that it think it can omit. You can mimic this by calling include twice on the same file:

# don't load Revise
julia> mktemp() do f, io
           write(io, """
               struct A{T} end
               struct B{T, S}
                 a::A{<:T}
               end
               """)
           close(io)
           include(f)
           include(f)
       end
ERROR: LoadError: invalid redefinition of type B
Stacktrace:
 [1] top-level scope
   @ /tmp/jl_KJFFPN:2
 [2] include
   @ ./client.jl:489 [inlined]
 [3] (::var"#1#2")(f::String, io::IOStream)
   @ Main ./REPL[1]:10
 [4] mktemp(fn::var"#1#2", parent::String)
   @ Base.Filesystem ./file.jl:738
 [5] mktemp(fn::Function)
   @ Base.Filesystem ./file.jl:736
 [6] top-level scope
   @ REPL[1]:1
in expression starting at /tmp/jl_KJFFPN:2

but changing a::A{<:T} to just a::A{T} does not trigger that error.

@timholy timholy added the juliabug Bug is due to a julia bug label Jan 1, 2024
timholy added a commit to JuliaLang/julia that referenced this issue Jan 4, 2024
aviatesk added a commit to JuliaLang/julia that referenced this issue Jan 6, 2024
Fixes #52686
Fixes timholy/Revise.jl#770

---------

Co-authored-by: Jameson Nash <[email protected]>
Co-authored-by: Kristoffer Carlsson <[email protected]>
Co-authored-by: Shuhei Kadowaki <[email protected]>
aviatesk added a commit to JuliaLang/julia that referenced this issue Jan 6, 2024
Fixes #52686
Fixes timholy/Revise.jl#770

---------

Co-authored-by: Jameson Nash <[email protected]>
Co-authored-by: Kristoffer Carlsson <[email protected]>
Co-authored-by: Shuhei Kadowaki <[email protected]>
Drvi pushed a commit to RelationalAI/julia that referenced this issue Jun 7, 2024
Fixes JuliaLang#52686
Fixes timholy/Revise.jl#770

---------

Co-authored-by: Jameson Nash <[email protected]>
Co-authored-by: Kristoffer Carlsson <[email protected]>
Co-authored-by: Shuhei Kadowaki <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug juliabug Bug is due to a julia bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants