When a library returns a record with functions defined on it, there's no problem with assigning that record to a variable and calling the functions against the variable, but invalid C is generated if the functions are called directly on require()'s return value.
Code example
local M = @record{}
function M.show() print(1) end
return M
When named 'lib.nelua',
$ nelua -i 'local m = require("lib") m.show()'
1
$ nelua -i 'require("lib").show()'
/home/jfondren/.cache/nelua/eval_UX7k2sMerEs.c: In function ‘nelua_main’:
/home/jfondren/.cache/nelua/eval_UX7k2sMerEs.c:82:3: error: implicit declaration of function ‘lib2_M_show’ [-Werror=implicit-function-declaration]
82 | lib2_M_show();
| ^~~~~~~~~~~
cc1: some warnings being treated as errors
error: C compilation for '/home/jfondren/.cache/nelua/eval_UX7k2sMerEs' failed
Bug description
When a library returns a record with functions defined on it, there's no problem with assigning that record to a variable and calling the functions against the variable, but invalid C is generated if the functions are called directly on
require()
's return value.Code example
When named 'lib.nelua',
Environment
x86_64 linux Nelua 0.2.0-dev Build number: 1588 Git date: 2023-09-16 16:20:44 -0300 Git hash: 596fcca5c77932da8a07c249de59a9dff3099495 Semantic version: 0.2.0-dev.1588+596fcca5 Copyright (C) 2019-2022 Eduardo Bart (https://nelua.io/)