JakobOvrum/LuaD

Function wrapping wrongly requires at least one argument passed to a variadic function

aubade opened this issue · 2 comments

D rules permit passing zero arguments to a variadic function, but LuaD's current wrapping doesn't seem to permit this.

This code illustrates the issue:

import luad.all;
void func(LuaObject[] args...) {
    import std.stdio;
    writeln("Arguments passed: ", args.length);
}


void main() {
    auto lua = new LuaState();
    lua.openLibs();
    lua.globals["func"] = &func;
    func(); //Works fine


         lua.doString(`
        func()
    `); //Throws an exception.
}

I've fixed this locally by manually subtracting one from the required-argument-count check if std.traits.variadicFunctionStyle != Variadic.no. If this is an acceptible solution I'd be happy to file a pull request.

I've fixed this locally by manually subtracting one from the required-argument-count check if std.traits.variadicFunctionStyle != Variadic.no. If this is an acceptible solution I'd be happy to file a pull request.

Sounds like the correct fix. Please file, thanks :)

Fixed by #69.