aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Germain <bnt.germain@gmail.com>2025-07-22 16:29:37 +0200
committerBenoit Germain <bnt.germain@gmail.com>2025-07-22 16:29:37 +0200
commit01a44c4226be63760ec492f2a6a416331094f0c7 (patch)
treeb79772d38a65dcd979a634a5bc2bd1f1c4653a65 /src
parentc67c7bb2cde0d418f72c8ac1ef57f15669b8a2bf (diff)
downloadlanes-01a44c4226be63760ec492f2a6a416331094f0c7.tar.gz
lanes-01a44c4226be63760ec492f2a6a416331094f0c7.tar.bz2
lanes-01a44c4226be63760ec492f2a6a416331094f0c7.zip
workaround a possible Lua 5.5 bug when dumping functions (but it doesn't solve everything)
Diffstat (limited to 'src')
-rw-r--r--src/tools.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/tools.cpp b/src/tools.cpp
index aafb9e8..c6e9cc3 100644
--- a/src/tools.cpp
+++ b/src/tools.cpp
@@ -143,6 +143,11 @@ namespace tools {
143 int PushFunctionBytecode(lua_State* const L_, int const strip_) 143 int PushFunctionBytecode(lua_State* const L_, int const strip_)
144 { 144 {
145 luaL_Buffer B{}; 145 luaL_Buffer B{};
146 // WORKAROUND FOR Lua 5.5 beta: lua_dump followed by luaL_pushresult pops the function from the stack before adding the bytecode string
147 // so I need to duplicate it so that I end up with the original stack and the bytecode string pushed on top
148 if constexpr (LUA_VERSION_NUM == 505) {
149 lua_pushvalue(L_, kIdxTop);
150 }
146 int const result_{ luaW_dump(L_, local::buf_writer, &B, strip_) }; 151 int const result_{ luaW_dump(L_, local::buf_writer, &B, strip_) };
147 if (result_ == 0) { // documentation says it should always be the case (because our writer only ever returns 0), but better safe than sorry 152 if (result_ == 0) { // documentation says it should always be the case (because our writer only ever returns 0), but better safe than sorry
148 luaL_pushresult(&B); 153 luaL_pushresult(&B);