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

can't use revise #166

Open
untoreh opened this issue Jan 16, 2022 · 7 comments
Open

can't use revise #166

untoreh opened this issue Jan 16, 2022 · 7 comments
Labels
wontfix This will not be worked on

Comments

@untoreh
Copy link

untoreh commented Jan 16, 2022

I am getting this error if I try to use revise with comonicon:

│   exception =
│    type Entry has no field description
│    Stacktrace:
│      [1] getproperty(x::Comonicon.AST.Entry, f::Symbol)
│        @ Base Base.jl:42
│      [2] print_sig_brief(io::IOContext{IOBuffer}, cmd::Comonicon.AST.Entry, t::Comonicon.AST.Terminal)
│        @ Comonicon.AST ~/.julia/packages/Comonicon/e8ZTW/src/ast/printing.jl:224
│      [3] print_body(io::IOContext{IOBuffer}, cmd::Comonicon.AST.NodeCommand, t::Comonicon.AST.Terminal)
│        @ Comonicon.AST ~/.julia/packages/Comonicon/e8ZTW/src/ast/printing.jl:170
│      [4] print_cmd(io::IOContext{IOBuffer}, cmd::Comonicon.AST.NodeCommand, t::Comonicon.AST.Terminal)
│        @ Comonicon.AST ~/.julia/packages/Comonicon/e8ZTW/src/ast/printing.jl:103
│      [5] print_cmd(io::IOContext{IOBuffer}, cmd::Comonicon.AST.NodeCommand)
│        @ Comonicon.AST ~/.julia/packages/Comonicon/e8ZTW/src/ast/printing.jl:47
│      [6] sprint(f::typeof(Comonicon.AST.print_cmd), args::Tuple{Comonicon.AST.NodeCommand}; context::Pair{Symbol, Bool}, sizehint::Int64)
│        @ Base strings/io.jl:112
│      [7] (::Base.var"#sprint##kw")(::NamedTuple{(:context,), Tuple{Pair{Symbol, Bool}}}, ::typeof(sprint), f::typeof(Comonicon.AST.print_cmd), args::Tuple{Comonicon.AST.NodeCommand})
│        @ Base strings/io.jl:108
│      [8] help_str(x::Comonicon.AST.NodeCommand; color::Bool)
│        @ Comonicon.JuliaExpr ~/.julia/packages/Comonicon/e8ZTW/src/codegen/julia.jl:7
│      [9] (::Comonicon.JuliaExpr.var"#help_str##kw")(::NamedTuple{(:color,), Tuple{Bool}}, ::typeof(Comonicon.JuliaExpr.help_str), x::Comonicon.AST.NodeCommand)
│        @ Comonicon.JuliaExpr ~/.julia/packages/Comonicon/e8ZTW/src/codegen/julia.jl:7
│     [10] emit_error(cmd::Comonicon.AST.NodeCommand, msg::String; color::Bool)
│        @ Comonicon.JuliaExpr ~/.julia/packages/Comonicon/e8ZTW/src/codegen/julia.jl:19
│     [11] emit_error(cmd::Comonicon.AST.NodeCommand, msg::String)
│        @ Comonicon.JuliaExpr ~/.julia/packages/Comonicon/e8ZTW/src/codegen/julia.jl:18
│     [12] emit_body(cmd::Comonicon.AST.NodeCommand, ptr::Int64)
│        @ Comonicon.JuliaExpr ~/.julia/packages/Comonicon/e8ZTW/src/codegen/julia.jl:76
│     [13] emit(cmd::Comonicon.AST.Entry, ptr::Int64)
│        @ Comonicon.JuliaExpr ~/.julia/packages/Comonicon/e8ZTW/src/codegen/julia.jl:55
│     [14] emit(cmd::Comonicon.AST.Entry)
│        @ Comonicon.JuliaExpr ~/.julia/packages/Comonicon/e8ZTW/src/codegen/julia.jl:55
│     [15] top-level scope
│        @ ~/.julia/packages/Comonicon/e8ZTW/src/frontend/cast.jl:375
│    Revise evaluation error at /home/fra/.julia/packages/Comonicon/e8ZTW/src/frontend/cast.jl:375
│    
└ @ Revise ~/.julia/packages/Revise/jHTGK/src/packagedef.jl:708
@Roger-luo
Copy link
Collaborator

this seems to be a bug due to a specific command printing, how do you reproduce this error? I'm not able to debug anything without knowing how to trigger this

@Roger-luo Roger-luo added the question Further information is requested label Jan 18, 2022
@untoreh
Copy link
Author

untoreh commented Jan 21, 2022

This should trigger it

import Pkg
Pkg.add("Revise")
using Revise
Pkg.add("Comonicon")

using TOML
cfg = TOML.parsefile("Project.toml")
cfg["name"] = "ComTest"
open("Project.toml", "w") do f
    TOML.print(f, cfg)
end

mkpath("src/")

write("src/ComTest.jl", "module ComTest print(:hello) end")
using ComTest
Revise.revise(ComTest)

write("src/ComTest.jl", """
module ComTest
using Comonicon
@cast function one()
    print(:one)
end
@main
end
""")
Revise.revise()

write("src/ComTest.jl", "module ComTest print(:hello) end")
Revise.revise()

write("src/ComTest.jl", """
module ComTest
using Comonicon
@cast function one()
    print(:one)
end
@main
end
""")
Revise.revise()

write("src/ComTest.jl", "module ComTest print(:hello) end")
Revise.revise()

write("src/ComTest.jl", """
module ComTest
using Comonicon
@cast function one()
    print(:one)
end
@main
end
""")
Revise.revise()

@Roger-luo Roger-luo added bug Something isn't working and removed question Further information is requested labels Feb 2, 2022
@Roger-luo
Copy link
Collaborator

This is because Revise doesn't delete the old global CASTED_COMMANDS created by Comonicon when user revise the functions, so as a result the previous CASTED_COMMANDS is used in the later creation of the new commands.

I don't have a good way to fix this as Comonicon is really doing what is legit for Julia, but like struct cannot be revised, this happens to be one of the limitations of Revise. Someone might come up with a solution in the future but I don't know one for now.

@Roger-luo Roger-luo added wontfix This will not be worked on and removed bug Something isn't working labels Feb 2, 2022
@xgdgsc
Copy link
Contributor

xgdgsc commented Jun 4, 2023

Is it possible just detect Revise in macro if exists do nothing? Just like commented out code.

@Roger-luo
Copy link
Collaborator

I'm not sure because the macro in principle will be evaluated at precompile time thus when you load Revise after this I'm not sure how would this happen. But won't it be strange if the macro does nothing just because you load Revise?

@kescobo
Copy link

kescobo commented Jun 27, 2023

I'm running into this issue too - I've discovered that I can have the @casted functions call functions from another deved package, which can then be Revised, but then any time I want to update the stuff in the cli module, I have to restart.

Is there a recommended development workflow documented somewhere? As in, I don't have the full thing spec'd out and I'm working out my interfaces on the fly... Even with 1.9 the restart-latency every time I want to change something is really bogging me down.

@Roger-luo
Copy link
Collaborator

I don't have a good solution to this, what I usually do is not define the CLI and converge on the Julia API of the package first, then add @cast to the methods I want to export. Going back and forth on the CLI API usually means the Julia API is not stable anyway, so I'd just pick the easier problem to solve first.

But I do hope there can be a solution to this, I believe if there is some kind of mechanism to tell Revise it can delete and allocate a new global variable with a callback it should be possible to integrate, I asked in Revise issue but no one answers me... perhaps people are busy and not much attention is attract here, given this is a small UX thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

4 participants