chakravala / chakravala/Reduce.jl

Simple Reduce Statement Fails to Compile Inside Module

Open
#32 19 comments 1 reaction 0 assignees View on GitHub
bug question
Dominant language
Julia
Stars
249
Forks
16
PR merge metrics
No merged PRs in 30d

Description

The following code snippet runs just fine in Julia 1.2, unless it's put into a module.
```
module DebugModule

using ForceImport
@force using Reduce.Algebra
using ReduceLinAlg

f(a,b) = (:x - a) * (:x - b)
g(a,b) = int( f(a,b), :x)

# comment this out and the module loads, or simply copy and paste the code
# and it works
g0 = g(:a,:b) - sub( (:(x=b), ), g(:a,:b))

end # module
```
Now see what happens when I try to use this module.
```
julia> using DebugModule
[ Info: Recompiling stale cache file /home/matt/.julia/compiled/v1.2/DebugModule.ji for DebugModule [top-level]
ERROR: LoadError: Base.Meta.ParseError("invalid operator \"--\"")
Stacktrace:
[1] #parse#1(::Bool, ::Bool, ::Bool, ::typeof(Base.Meta.parse), ::String, ::Int64) at ./meta.jl:129
[2] #parse at ./tuple.jl:0 [inlined]
[3] #parse#4(::Bool, ::Bool, ::typeof(Base.Meta.parse), ::String) at ./meta.jl:160
[4] parse at ./meta.jl:160 [inlined]
[5] |>(::String, ::typeof(Base.Meta.parse)) at ./operators.jl:854
[6] #parse_expr#46(::Int64, ::typeof(Reduce.parse_expr), ::String, ::Reduce.RExpr) at /home/matt/.julia/packages/Reduce/4dmwd/src/parser.jl:317
[7] (::getfield(Reduce, Symbol("#kw##parse_expr")))(::NamedTuple{(:be,),Tuple{Int64}}, ::typeof(Reduce.parse_expr), ::String, ::Reduce.RExpr) at ./none:0
[8] #parse#76(::Int64, ::typeof(parse), ::Reduce.RExpr) at /home/matt/.julia/packages/Reduce/4dmwd/src/parser.jl:438
[9] parse at /home/matt/.julia/packages/Reduce/4dmwd/src/parser.jl:438 [inlined]
[10] convert at /home/matt/.julia/packages/Reduce/4dmwd/src/rexpr.jl:414 [inlined]
[11] unfold_expr_force(::Symbol, ::Symbol, ::Expr, ::Symbol) at /home/matt/.julia/packages/Reduce/4dmwd/src/parser.jl:847
[12] #unfold_expr#77(::Bool, ::typeof(Reduce.unfold_expr), ::Symbol, ::Symbol, ::Expr, ::Symbol) at /home/matt/.julia/packages/Reduce/4dmwd/src/parser.jl:806
[13] unfold_expr(::Symbol, ::Symbol, ::Expr, ::Symbol) at /home/matt/.julia/packages/Reduce/4dmwd/src/parser.jl:801
[14] unfold(::Symbol, ::Symbol, ::Expr, ::Symbol) at /home/matt/.julia/packages/Reduce/4dmwd/src/parser.jl:863
[15] int(::Expr, ::Symbol) at /home/matt/.julia/packages/Reduce/4dmwd/src/parser.jl:793
[16] g(::Symbol, ::Symbol) at /mnt/WorkSpace/projects/Maestro/GlucoseSource/DebugModule.jl:10
[17] top-level scope at /mnt/WorkSpace/projects/Maestro/GlucoseSource/DebugModule.jl:14
[18] include at ./boot.jl:328 [inlined]
[19] include_relative(::Module, ::String) at ./loading.jl:1094
[20] include(::Module, ::String) at ./Base.jl:31
[21] top-level scope at none:2
[22] eval at ./boot.jl:330 [inlined]
[23] eval(::Expr) at ./client.jl:432
[24] top-level scope at ./none:3
in expression starting at /mnt/WorkSpace/projects/Maestro/GlucoseSource/DebugModule.jl:14
ERROR: Failed to precompile DebugModule [top-level] to /home/matt/.julia/compiled/v1.2/DebugModule.ji.
Stacktrace:
[1] compilecache(::Base.PkgId, ::String) at ./loading.jl:1253
[2] _require(::Base.PkgId) at ./loading.jl:1013
[3] require(::Base.PkgId) at ./loading.jl:911
[4] require(::Module, ::Symbol) at ./loading.jl:906

julia>
```
If I copy and paste the code into the julia REPL it works fine and the module loads if the last line,
`g0 = g(:a,:b) - sub( (:(x=b), ), g(:a,:b))` is commented out. This looks like a bug to me.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.