Skip to content

Commit 28def96

Browse files
Merge pull request #29 from shashi/s/0-arg
support 0-arg functions
2 parents 4168d9d + 1b3af21 commit 28def96

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/RuntimeGeneratedFunctions.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ struct RuntimeGeneratedFunction{argnames, cache_tag, context_tag, id, B} <: Func
5454
body::B
5555
function RuntimeGeneratedFunction(cache_tag, context_tag, ex; opaque_closures = true)
5656
def = splitdef(ex)
57-
args, body = normalize_args(def[:args]), def[:body]
57+
args = normalize_args(get(def, :args, Symbol[]))
58+
body = def[:body]
5859
if opaque_closures && isdefined(Base, :Experimental) &&
5960
isdefined(Base.Experimental, Symbol("@opaque"))
6061
body = closures_to_opaque(body)

test/runtests.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ ex3 = :(function (_du::T, _u::Vector{E}, _p::P, _t::Any) where {T <: Vector, E,
2828
nothing
2929
end)
3030

31+
f0 = @RuntimeGeneratedFunction(:(()->42))
3132
f1 = @RuntimeGeneratedFunction(ex1)
3233
f2 = @RuntimeGeneratedFunction(ex2)
3334
f3 = @RuntimeGeneratedFunction(ex3)
3435

36+
@test f0() === 42
37+
3538
@test f1 isa Function
3639

3740
du = rand(2)

0 commit comments

Comments
 (0)