From e3e45fb330e29cc9b203a70b649e61f62697f88d Mon Sep 17 00:00:00 2001 From: Li Jin Date: Tue, 31 Jan 2023 18:17:31 +0800 Subject: fix stack overflow issue in yue.to_ast(). --- src/yue.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/yue.cpp') diff --git a/src/yue.cpp b/src/yue.cpp index 5679e58..7adde70 100644 --- a/src/yue.cpp +++ b/src/yue.cpp @@ -270,15 +270,6 @@ int main(int narg, const char** args) { ; #ifndef YUE_COMPILER_ONLY if (narg == 1) { - lua_State* L = luaL_newstate(); - openlibs(L); - DEFER(lua_close(L)); - pushYue(L, "insert_loader"sv); - if (lua_pcall(L, 0, 0, 0) != 0) { - std::cout << lua_tostring(L, -1) << '\n'; - return 1; - } - int count = 0; linenoise::SetMultiLine(false); linenoise::SetCompletionCallback([](const char* editBuffer, std::vector& completions) { std::string buf = editBuffer; @@ -326,6 +317,15 @@ int main(int narg, const char** args) { break; } }); + lua_State* L = luaL_newstate(); + openlibs(L); + DEFER(lua_close(L)); + pushYue(L, "insert_loader"sv); + if (lua_pcall(L, 0, 0, 0) != 0) { + std::cout << lua_tostring(L, -1) << '\n'; + return 1; + } + int count = 0; std::cout << "Yuescript "sv << yue::version << '\n'; while (true) { count++; -- cgit v1.2.3-55-g6feb