natecraddock / ziglua

Zig bindings for the Lua C API
MIT License
269 stars 36 forks source link

luajit: opening standard library fails #64

Closed rockorager closed 7 months ago

rockorager commented 8 months ago

I know luajit support is in it's infancy but wanted to report that opening the standard libraries with it fails. I can swap out for 5.2 through 5.4 and openLibs or openBase work fine, but luajit fails:

/home/tim/.cache/zig/p/1220bc58b81db27e4a04f61703e0929fa3ec780a24698483aee1b349dee2cf9dd96a/src/lib.zig:2536:16: error: member function expected 1 argument(s), found 2
        try lua.loadFile(file_name, .binary_text);
            ~~~^~~~~~~~~
/home/tim/.cache/zig/p/1220bc58b81db27e4a04f61703e0929fa3ec780a24698483aee1b349dee2cf9dd96a/src/lib.zig:2652:5: note: function declared here
    fn loadFile51(lua: *Lua, file_name: [:0]const u8) !void {
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rockorager commented 8 months ago

Note: this does happen with 5.1 also. My original text said 5.1 worked but I have verified it doesn't (same error).

natecraddock commented 8 months ago

Hey!

that opening the standard libraries with it fails

Do you mean it segfaults/panics? I ran into this recently and I have a TODO comment to look into this more. If that's the case, I'll re-prioritize it and work on it sooner!

I think loadFile is one of the last functions that doesn't have test coverage (I just never got around to adding it). So I'll make sure to get that tested!

rockorager commented 8 months ago

Do you mean it segfaults/panics? I ran into this recently and I have a TODO comment to look into this more. If that's the case, I'll re-prioritize it and work on it sooner!

Yep, my bad...it segfaults. Thanks for looking into it!

natecraddock commented 7 months ago

Turns out the functions for opening libraries aren't meant to be called directly. Thanks again for reporting this!

I made a separate issue for loadFile: https://github.com/natecraddock/ziglua/issues/69