diff --git a/src/RuntimeGeneratedFunctions.jl b/src/RuntimeGeneratedFunctions.jl index e232917..5bddd4f 100644 --- a/src/RuntimeGeneratedFunctions.jl +++ b/src/RuntimeGeneratedFunctions.jl @@ -54,7 +54,8 @@ struct RuntimeGeneratedFunction{argnames, cache_tag, context_tag, id, B} <: Func body::B function RuntimeGeneratedFunction(cache_tag, context_tag, ex; opaque_closures = true) def = splitdef(ex) - args, body = normalize_args(def[:args]), def[:body] + args = normalize_args(get(def, :args, Symbol[])) + body = def[:body] if opaque_closures && isdefined(Base, :Experimental) && isdefined(Base.Experimental, Symbol("@opaque")) body = closures_to_opaque(body) diff --git a/test/runtests.jl b/test/runtests.jl index 768ea94..53a718b 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -28,10 +28,13 @@ ex3 = :(function (_du::T, _u::Vector{E}, _p::P, _t::Any) where {T <: Vector, E, nothing end) +f0 = @RuntimeGeneratedFunction(:(()->42)) f1 = @RuntimeGeneratedFunction(ex1) f2 = @RuntimeGeneratedFunction(ex2) f3 = @RuntimeGeneratedFunction(ex3) +@test f0() === 42 + @test f1 isa Function du = rand(2)