lewis
May 11, 2020, 7:07pm
1
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]
lewis
May 11, 2020, 7:15pm
2
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.
lewis
May 11, 2020, 8:45pm
4
I have nothing named “Variable” anywhere in the module. More likely this came from a package.
lewis:
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
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
lewis
May 11, 2020, 8:55pm
6
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
`Variable` is a struct representing a variable with an asigned value.
By calling the function [`locals`](@ref) on a [`Frame`](@ref) a
`Vector` of `Variable`'s is returned.
Important fields:
- `value::Any`: the value of the local variable.
- `name::Symbol`: the name of the variable as given in the source code.
- `isparam::Bool`: if the variable is a type parameter, for example `T` in `f(x::T) where {T} = x`.
- `is_captured_closure::Bool`: if the variable has been captured by a closure
"""
struct Variable
value::Any
name::Symbol
isparam::Bool
is_captured_closure::Bool
end
Variable(value, name) = Variable(value, name, false, false)
Variable(value, name, isparam) = Variable(value, name, isparam, false)
Base.show(io::IO, var::Variable) = (print(io, var.name, " = "); show(io,var.value))
Base.isequal(var1::Variable, var2::Variable) =
var1.value == var2.value && var1.name == var2.name && var1.isparam == var2.isparam &&
and the error you got after updating is because JuliaInterpreter.jl released a new version which included a change to that struct
https://github.com/JuliaDebug/JuliaInterpreter.jl/pull/388/files#diff-1f61f32925620a8c37482af6f9a5d108R272
and Revise/Julia can’t handle hot reloading of struct redefinitions.
6 Likes
lewis
May 11, 2020, 9:29pm
8
Perfect. The correct answer.
And reload all was all that had to happen.