Closed torfjelde closed 3 years ago
So the MWE here is something like
julia> @generated f() = Expr(:isdefined, :($(QuoteNode(Float64))))
f (generic function with 1 method)
julia> f()
true
julia> JuliaInterpreter.@interpret f()
ERROR: unrecognized isdefined node $(QuoteNode(Float64))
which seems like a weird function to write anyways (in Zygote it's generated somewhere here).
diff --git a/src/interpret.jl b/src/interpret.jl
index ba26275..089e4a7 100644
--- a/src/interpret.jl
+++ b/src/interpret.jl
@@ -421,6 +421,8 @@ function check_isdefined(frame, @nospecialize(node))
return isdefined(node.mod, node.name)
elseif isa(node, Symbol)
return isdefined(moduleof(frame), node)
+ elseif isa(node, QuoteNode)
+ return isdefined(moduleof(frame), Symbol(node.value))
end
error("unrecognized isdefined node ", node)
end
is a possible fix, but I don't know if it actually makes sense...
I think the right return value here would just be true
, see #477. A lot of Cassette style code transformations replace slots with QuoteNodes, so I think we should support this.
Oh wow, that was quick! Thanks!
Came across the following issue:
Not clear to me if this is Zygote doing something weird or if this is JuliaInterpreter lacking a support for this particular case. Anyways, hope this is useful!
Packages