JuliaMath / Calculus.jl

Calculus functions in Julia
Other
275 stars 78 forks source link

Evaluation into the closed module `Calculus` breaks incremental compilation... #151

Open omalled opened 3 years ago

omalled commented 3 years ago

I have a complex code that broke when I switched from Julia 1.4 to Julia 1.5. The breakage seems to be intertwined with the Calculus package. I have tried but failed to produce an MWE (sorry about that). The context is that my complex code is doing some code generation in a macro and then calling Calculus.simplify(ex) on some generated expressions. The error I get when running my complex code is

Evaluation into the closed module `Calculus` breaks incremental compilation because the side effects will not be permanent. This is likely due to some other module mutating `Calculus` with `eval` during precompilation - don't do this.

The stack trace leads me to this line. It seems like the eval is the source of the problem. Would there be any harm in evaling in Main rather than Calculus itself? Switching that line to

return (@static (VERSION < v"0.7.0-DEV.5149") ? eval : Core.eval)(Main, ex)

solves my problem and all the tests still pass. I'd be happy to submit a pull request, but not sure if that solution would be accepted.