It’s really not clear to me what is and isn’t allowed in a generated function. I get this error:
ERROR: generated function body is not pure. this likely means it contains a closure or comprehension.
Ok, but where’s the problem? Is there any way of narrowing it down? Especially confusing is trying to pin down exactly what closures are unallowable. For example, this code works with no problems:
@generated function foo(x) g(y) = :($(one(x)) + $(one(y))) g(x) end
So maybe the limitation is not really with closures, but state that’s stored outside the generated function. Is that right?
My generated code had called functions that call
rand, and I’ve been moving things around with no luck yet. It feels like I’m stumbling around in the dark here, are there any guidelines for debugging generated functions I should be following?