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

Export grammar in precompilation step fails #62

Open
nicolaefilat opened this issue Mar 27, 2024 · 0 comments
Open

Export grammar in precompilation step fails #62

nicolaefilat opened this issue Mar 27, 2024 · 0 comments

Comments

@nicolaefilat
Copy link
Contributor

nicolaefilat commented Mar 27, 2024

ERROR: LoadError: Evaluation into the closed module `HerbGrammar` breaks incremental compilation because the side effects will not be permanent. This is likely due to some other module mutating `HerbGrammar` with `eval` during precompilation - don't do this.
Stacktrace:
 [1] eval
   @ ./boot.jl:368 [inlined]
 [2] eval
   @ ~/.julia/packages/HerbGrammar/x0E9w/src/HerbGrammar.jl:1 [inlined]
 [3] parse_rule!(v::Vector{Any}, ex::Expr)
   @ HerbGrammar ~/.julia/packages/HerbGrammar/x0E9w/src/cfg/cfg.jl:121
 [4] expr2cfgrammar(ex::Expr)
   @ HerbGrammar ~/.julia/packages/HerbGrammar/x0E9w/src/cfg/cfg.jl:64
 [5] expr2csgrammar(ex::Expr)
   @ HerbGrammar ~/.julia/packages/HerbGrammar/x0E9w/src/csg/csg.jl:59
 [6] var"@csgrammar"(__source__::LineNumberNode, __module__::Module, ex::Any)
   @ HerbGrammar ~/.julia/packages/HerbGrammar/x0E9w/src/csg/csg.jl:98
 [7] include
   @ ./Base.jl:419 [inlined]
 [8] include_package_for_output(pkg::Base.PkgId, input::String, depot_path::Vector{String}, dl_load_path::Vector{String}, load_path::Vector{String}, concrete_deps::Vector{Pair{Base.PkgId, UInt64}}, source::Nothing)
   @ Base ./loading.jl:1554
 [9] top-level scope
   @ stdin:1

The fix is available on mattermost, we just have to implement it.

function parse_rule!(v::Vector{Any}, ex::Expr)
 if ex.head == :call && ex.args[1] == :|
     terms = length(ex.args) == 2 ?
     collect(ex.args[2].args[2]:ex.args[2].args[3]) :    #|(a:c) case
     ex.args[2:end]                 #a|b|c case
     for t in terms
         parse_rule!(v, t)
     end
 else
     push!(v, ex)
 end
end
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

1 participant