What does this error message mean

It should be sort of obvious: I am redefining a const somewhere.

Which const could it be?

I have nothing named Variable anywhere. I only have 4 structs anywhere in the code. None redefine another.

What is the reference to “toplevel”?

julia> using CovidSim
Revise.LogRecord(Error, evaluation error starting at /Users/lewis/Dropbox/Online Coursework/Covid/src/toplevel:257, lowered, Revise_e943ed8b, "/Users/lewis/.julia/packages/Revise/MgvIv/src/lowered.jl", 106, (mod=JuliaInterpreter, ex=begin
    #= toplevel:257 =#
    struct Variable
        #= /Users/lewis/.julia/packages/JuliaInterpreter/R1LXQ/src/types.jl:269 =#
        value::Any
        #= /Users/lewis/.julia/packages/JuliaInterpreter/R1LXQ/src/types.jl:270 =#
        name::Symbol
        #= /Users/lewis/.julia/packages/JuliaInterpreter/R1LXQ/src/types.jl:271 =#
        isparam::Bool
        #= /Users/lewis/.julia/packages/JuliaInterpreter/R1LXQ/src/types.jl:272 =#
        is_captured_closure::Bool
    end
end)invalid redefinition of constant Variable
Stacktrace:
 [1] top-level scope at none:0)[ Info: Precompiling CovidSim [top-level]

Never mind. I “up’ed” my packages; quit Julia; restarted Julia in the same terminal session. I’d been in the same terminal session for about a week. That’s just asking for trouble. Memory corruption or Revise got confused. Quit terminal. Open new terminal. Problem gone.

Don’t worry about this. Long sessions are always risky. Pays to purge every day. And it’s good practice to make things clean and repeatable.

You probably tried to redefine the struct Variable with a different definition. This is not possible in Julia and indeed the only solution is to restart the whole Julia process if you wish to redefine it with the same name.

I have nothing named “Variable” anywhere in the module. More likely this came from a package.

It’s right there on the 4th line of the code you posted:

julia> using CovidSim
Revise.LogRecord(Error, evaluation error starting at /Users/lewis/Dropbox/Online Coursework/Covid/src/toplevel:257, lowered, Revise_e943ed8b, "/Users/lewis/.julia/packages/Revise/MgvIv/src/lowered.jl", 106, (mod=JuliaInterpreter, ex=begin
    #= toplevel:257 =#
    struct Variable

I can do a text search across all files in the project. No such thing.

What I pasted is the error message. It refers to something that isn’t present. I suspect it was in a package that was subsequently upgraded, which is why it disappeared when I restarted terminal and Julia—with no change to my code.

Let’s let it go. It’s one those mysteries. If it had persisted, then there’d be something to figure out.

1 Like

The struct Variable is from JuliaInterpreter.jl

and the error you got after updating is because JuliaInterpreter.jl released a new version which included a change to that struct

and Revise/Julia can’t handle hot reloading of struct redefinitions.

6 Likes

Perfect. The correct answer.

And reload all was all that had to happen.