summaryrefslogtreecommitdiff
path: root/src/table.rs
diff options
context:
space:
mode:
authorAlex Orlenko <zxteam@protonmail.com>2022-10-29 23:02:08 +0100
committerAlex Orlenko <zxteam@protonmail.com>2022-10-29 23:02:19 +0100
commita7278cab78c95239c142dba706a3f397a3e2f2ca (patch)
tree30019a9cec465921052f9df672bc19cc69cea512 /src/table.rs
parente1bbd00a33df327fa3aa04e8f579baef5e31150c (diff)
downloadmlua-a7278cab78c95239c142dba706a3f397a3e2f2ca.zip
Fix `Table::raw_push` for luau when readonly
Diffstat (limited to 'src/table.rs')
-rw-r--r--src/table.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/table.rs b/src/table.rs
index 94b3da4..523ec6b 100644
--- a/src/table.rs
+++ b/src/table.rs
@@ -322,7 +322,13 @@ impl<'lua> Table<'lua> {
let len = ffi::lua_rawlen(state, -2) as Integer;
ffi::lua_rawseti(state, -2, len + 1);
}
- if lua.unlikely_memory_error() {
+
+ #[cfg(not(feature = "luau"))]
+ let protect = !lua.unlikely_memory_error();
+ // If Luau table is readonly it will throw an exception
+ #[cfg(feature = "luau")]
+ let protect = !lua.unlikely_memory_error() || self.is_readonly();
+ if !protect {
callback(lua.state);
} else {
protect_lua!(lua.state, 2, 0, fn(state) callback(state))?;