From 4937e32a628b6950f698f147a121bac6376dd3ba Mon Sep 17 00:00:00 2001 From: Li Jin Date: Mon, 11 Jan 2021 10:11:47 +0800 Subject: fix issue #34. --- src/MoonP/moon_compiler.cpp | 3 ++- src/moonp.cpp | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/MoonP/moon_compiler.cpp b/src/MoonP/moon_compiler.cpp index 75f1b35..d49cf14 100644 --- a/src/MoonP/moon_compiler.cpp +++ b/src/MoonP/moon_compiler.cpp @@ -53,7 +53,7 @@ inline std::string s(std::string_view sv) { return std::string(sv); } -const std::string_view version = "0.4.21"sv; +const std::string_view version = "0.4.22"sv; const std::string_view extension = "mp"sv; class MoonCompilerImpl { @@ -106,6 +106,7 @@ public: str_list out; pushScope(); _enableReturn.push(_info.moduleName.empty()); + _varArgs.push(true); transformBlock(_info.node.to()->block, out, config.implicitReturnRoot ? ExpUsage::Return : ExpUsage::Common, nullptr, true); diff --git a/src/moonp.cpp b/src/moonp.cpp index 30cbe43..27c6016 100644 --- a/src/moonp.cpp +++ b/src/moonp.cpp @@ -331,7 +331,14 @@ int main(int narg, const char** args) { lua_pop(L, 1); pushMoonp(L, "pcall"sv); lua_insert(L, -2); - if (lua_pcall(L, 1, 2, 0) != 0) { + int argCount = 0; + i++; + while (i < narg) { + argCount++; + lua_pushstring(L, args[i]); + i++; + } + if (lua_pcall(L, 1 + argCount, 2, 0) != 0) { std::cout << lua_tostring(L, -1) << '\n'; return 1; } -- cgit v1.2.3-55-g6feb