-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Description
Any function that is called within a generated function needs to be defined before the generated function definition otherwise we encounter a MethodError from the world being too new:
julia> f1() = 1
f1 (generic function with 1 method)
julia> @generated function g1()
v = f1()
quote
return $v
end
end
g1 (generic function with 1 method)
julia> g1()
1vs.
julia> @generated function g2()
v = f2()
quote
return $v
end
end
g2 (generic function with 1 method)
julia> f2() = 1
f2 (generic function with 1 method)
julia> g2()
ERROR: MethodError: no method matching f2()
The applicable method may be too new: running in world age 21396, while current world is 21397.
Closest candidates are:
f2() at REPL[5]:1 (method too new to be called from this world context.)
Stacktrace:
[1] g2(...) at ./REPL[4]:2Introduced with #17057
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels