diff options
Diffstat (limited to 'src/tools.cpp')
| -rw-r--r-- | src/tools.cpp | 5 |
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); |
