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

Revise not working anymore for files that contain type definition (but the type is not changed) #734

Closed
thofma opened this issue Feb 21, 2023 · 12 comments

Comments

@thofma
Copy link

thofma commented Feb 21, 2023

I noticed a regression with files that contain type definitions.

I have a file, which contains a type definition

mutable struct A
  x
end

and some method definitions

function g()
end

If the file is tracked with Revise and I change g, I get:

┌ Error: Failed to revise ...
│   exception =
│    invalid redefinition of constant A

which I did not expect, since I did not change the type definition. This is with Revise version 3.5.1.

I quickly tried with Revise version 3.4.0 and it is working as expected. This means, that when only g is changed but not A, then the file is revised properly.

@lgoettgens
Copy link

The same thing happened to me. However, it only occurs in a subset of the files of the given structure, and I cannot find any way to distinguish them.
Pinning the version to 3.4.0 seems to be a workaround for now, thanks for the tip @thofma .

@fingolfin
Copy link

@timholy any idea what might be causing this?

@timholy
Copy link
Owner

timholy commented Mar 22, 2023

I need to spend a week or so on Revise. No time right now though.

@fingolfin
Copy link

It doesn't suffice anymore to pin Revise to 3.4.0 as it fails to precompile one also has to pin JuliaInterpreter to 0.9.26

@kahaaga
Copy link

kahaaga commented Dec 13, 2023

Same issue here with Revise v3.5.10 on Julia 1.9.4, running on a Macbook Air M2 (2022 model), macOS Ventura 13.3.

I'm tracking changes in a package I'm developing. Any change to files that contain a type definition triggers the same error as above, even if the type definition was not changed.

The following workaround solves it for me (thanks, @fingolfin):

(@v1.9) pkg> activate . # in whatever project folder you're working
(MyProject) pkg> add JuliaInterpreter@0.9.26
(MyProject) pkg> add Revise@3.4.0
julia> using Revise, MyProject

@timholy
Copy link
Owner

timholy commented Dec 30, 2023

At least with Julia 1.10 and LoweredCodeUtils 2.4.0, I cannot replicate this. Here's my setup:

tim@diva:/tmp/TestRevise$ ls -l
total 12
-rw-r--r-- 1 tim tim  186 Dec 30 10:36 Manifest.toml
-rw-r--r-- 1 tim tim  128 Dec 30 10:35 Project.toml
drwxr-xr-x 2 tim tim 4096 Dec 30 10:35 src
tim@diva:/tmp/TestRevise$ cat src/TestRevise.jl
module TestRevise

export g

mutable struct A
    x
end

function g()
end

end # module TestRevise

And then

julia> using TestRevise
Precompiling TestRevise
  1 dependency successfully precompiled in 1 seconds

julia> g()

# Now edit `g` to return 1
julia> 1+1
2

julia> g()
1

All seems working as expected.

@aviatesk
Copy link
Collaborator

I haven't been able to replicate this issue with Julia 1.10 and the latest versions of Revise and its dependencies. So it seems reasonable to close the issue at this point.

@timholy timholy closed this as completed Dec 31, 2023
@thofma
Copy link
Author

thofma commented Dec 31, 2023

I can still reproduce this, although with a slightly more complicated file. I will try to find a small example.

@thofma
Copy link
Author

thofma commented Dec 31, 2023

With the following, it still fails for me:

 /tmp/TestRevise  cat src/TestRevise.jl
module TestRevise

abstract type A{S, T} end

mutable struct B{S} <: A{S, B}
end

g() = 2

end # module TestRevise
julia> TestRevise.g()
1

# Now edit g
julia> 1 + 1
 Error: Failed to revise /tmp/TestRevise/src/TestRevise.jl
│   exception =
│    invalid redefinition of constant TestRevise.B
│    Stacktrace:
│     [1] top-level scope
│       @ /tmp/TestRevise/src/TestRevise.jl:5
│    Revise evaluation error at /tmp/TestRevise/src/TestRevise.jl:5

Can you reproduce @aviatesk?

@lgoettgens
Copy link

I can reproduce it with the mwe from #734 (comment). with Revise v3.5.12 and JuliaInterpreter v0.9.27.

The workaround from #734 (comment) unfortunately no longer works for me.

@thofma
Copy link
Author

thofma commented Jan 5, 2024

It is a dup of #770

@lgoettgens
Copy link

I don't think so. I compiled julia with JuliaLang/julia#52748 and the example from #770 (comment) is fixed, but the one from #734 (comment) still fails

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

6 participants