Closed KirillZubov closed 3 years ago
using RuntimeGeneratedFunctions RuntimeGeneratedFunctions.init(@__MODULE__) u = :((x; y=1)->begin x+y end) f = @RuntimeGeneratedFunction(u) julia> f RuntimeGeneratedFunction(#=in Main=#, :((x,)->begin #= none:1 =# #= none:2 =# x + y end)) julia> f(1) ERROR: UndefVarError: y not defined Stacktrace: [1] macro expansion at ./none:2 [inlined] [2] macro expansion at /Users/kirill/.julia/packages/RuntimeGeneratedFunctions/fIcZp/src/RuntimeGeneratedFunctions.jl:80 [inlined] [3] macro expansion at ./none:0 [inlined] [4] generated_callfunc at ./none:0 [inlined] [5] (::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{var"#_RuntimeGeneratedFunctions_ModTag",(0xef, 0xe9, 0xe5, 0x37, 0x34, 0xb6, 0x09, 0xf2, 0x26, 0x77, 0xdd, 0x85, 0xf5, 0xc9, 0xbc, 0x5c, 0xcf, 0x72, 0x1e, 0x97, 0xfd, 0x79, 0x63, 0x69, 0x13, 0x28, 0x90, 0xdc, 0x30, 0x60, 0xaf, 0x27, 0x7e, 0xf0, 0x10, 0xa1, 0xae, 0x88, 0xbb, 0x9e, 0xb6, 0x97, 0x5d, 0x6e, 0xc5, 0x6f, 0x3e, 0x20, 0x2e, 0x47, 0x31, 0x6e, 0x04, 0x2c, 0x0b, 0x03, 0x61, 0x6e, 0xb9, 0xab, 0xd6, 0x2e, 0xaa, 0xae),(:x,)})(::Int64) at /Users/kirill/.julia/packages/RuntimeGeneratedFunctions/fIcZp/src/RuntimeGeneratedFunctions.jl:68 [6] top-level scope at none:1
Manually drop the kwargs down to positional args and compile the inner function. That's what Base does anyways. That's a workaround and we can add that here as well, but it's not too hard to do by hand.