Skip to content

Commit 7e88715

Browse files
authored
Remove restriction on the type of require results. (#227)
We originally implemented a restriction on require results being a table or function so that scripts would intrinsically be forwards-compatible as they evolve. To my surprise, this is a controversial choice. As part of the as-of-yet-unwritten style guide of Lute, we'll never return anything that is not a table or function, but users are free to do how they see fit.
1 parent 942a04a commit 7e88715

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

runtime/src/require.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,7 @@ static int load(lua_State* L, void* ctx, const char* chunkname, const char* cont
269269
const std::string prefix = "module " + std::string(chunknameView.substr(1)) + " must";
270270

271271
if (lua_gettop(ML) == 0)
272-
lua_pushstring(ML, (prefix + " return a value").c_str());
273-
else if (!lua_istable(ML, -1) && !lua_isfunction(ML, -1))
274-
lua_pushstring(ML, (prefix + " return a table or function").c_str());
272+
lua_pushstring(ML, (prefix + " return a value, if it has no return value, you should explicitly return `nil`").c_str());
275273
}
276274
else if (status == LUA_YIELD)
277275
{

0 commit comments

Comments
 (0)