Evaluation into closed module - what's wrong?

Hi metaprogramming afficionados,

The package SparseConnectivityTracer.jl works by operator overloading, like ForwardDiff.jl or Measurements.jl. We overload operations on new number types called ConnectivityTracer, GradientTracer and HessianTracer, in order to track dependencies of a function’s outputs on its inputs.

I am currently trying to support SpecialFunctions.jl with a package extension, but the tests fail with the following error:

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

I don’t understand this error message, and I’m a real noob at metaprogramming. My best guess is that it is related to me using @eval inside functions.

Would anyone be so kind as to take a look at the PR and try to figure out what I did wrong? I added more details in the PR description

Related topic, which did not fix my issue:

Have you tried @eval $ms function $fns(...) ... end instead of @eval function $ms.$fns(...) ... end?

From the docs (emphasis mine):

help?> @eval
@eval [mod,] ex

Evaluate an expression with values interpolated into it using eval. If two arguments are provided, the first is the module to evaluate in.

The issue is not your evals. Rather you are calling a function during the extension’s init which calls @eval within SCT.

Within which module should i call @eval then? Base/SpecialFunctions?

It doesn’t seem possible to @eval into the calling scope itself :thinking: