macro replay in JET causes `gensym` to emit the same symbol twice which causes havoc in ResumableFunctions.jl generated functions · Issue #814 · aviatesk/JET.jl · GitHub
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
macro replay in JET causes gensym to emit the same symbol twice which causes havoc in ResumableFunctions.jl generated functions #814
In ResumableFunctions.jl there are a few places where a macro does something akin to this (creating a function with a unique name, "compiling" it, and then looking up its only method as a way to learn something about the type inference that was done):
unique_symbol = gensym()
func_expr = quote
function $unique_symbol($arg)
...
end
end
func = Core.eval(__module__, func_expr)
... = only(methods(func, Tuple)) # `only` is used here somewhat defensively, because it would not make sense for this unique function to have multiple methods
However, when JET runs its analyzing pass, this macro is executed a second time producing the exact same gensym.
This was noticed in the JET analysis done in CI for QuantumSavory.jl, which depends on ResumableFunctions.jl
It started happening after some fixes that were contributed by @vtjnash in JuliaDynamics/ResumableFunctions.jl#147 -- while the fixes are correct to the best of my knowledge, they unveiled this otherwise latent issue.
Suggested fix in ResumableFunctions.jl in JuliaDynamics/ResumableFunctions.jl#159 (I would appreciate advice on whether the fix is good from someone more experienced).
Most of this was analyzed and reported by codex 5.4, but the entirety of this report is written by me after reading the analysis.
Activity