Skip to content

Commit 9def001

Browse files
author
Your Name
committed
fix luau compiler bug
1 parent eb63755 commit 9def001

File tree

2 files changed

+34
-19
lines changed

2 files changed

+34
-19
lines changed

src/state/raw.rs

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,28 +1217,42 @@ impl RawLua {
12171217
{
12181218
unsafe extern "C-unwind" fn call_callback(state: *mut ffi::lua_State) -> c_int {
12191219
let upvalue = get_userdata::<ContinuationUpvalue>(state, ffi::lua_upvalueindex(1));
1220-
callback_error_ext_yieldable(state, (*upvalue).extra.get(), true, |extra, nargs| {
1221-
// Lua ensures that `LUA_MINSTACK` stack spaces are available (after pushing arguments)
1222-
// The lock must be already held as the callback is executed
1223-
let rawlua = (*extra).raw_lua();
1224-
match (*upvalue).data {
1225-
Some(ref func) => (func.0)(rawlua, nargs),
1226-
None => Err(Error::CallbackDestructed),
1227-
}
1228-
})
1220+
callback_error_ext_yieldable(
1221+
state,
1222+
(*upvalue).extra.get(),
1223+
true,
1224+
|extra, nargs| {
1225+
// Lua ensures that `LUA_MINSTACK` stack spaces are available (after pushing
1226+
// arguments) The lock must be already held as the callback is
1227+
// executed
1228+
let rawlua = (*extra).raw_lua();
1229+
match (*upvalue).data {
1230+
Some(ref func) => (func.0)(rawlua, nargs),
1231+
None => Err(Error::CallbackDestructed),
1232+
}
1233+
},
1234+
true,
1235+
)
12291236
}
12301237

12311238
unsafe extern "C-unwind" fn cont_callback(state: *mut ffi::lua_State, status: c_int) -> c_int {
12321239
let upvalue = get_userdata::<ContinuationUpvalue>(state, ffi::lua_upvalueindex(1));
1233-
callback_error_ext_yieldable(state, (*upvalue).extra.get(), true, |extra, nargs| {
1234-
// Lua ensures that `LUA_MINSTACK` stack spaces are available (after pushing arguments)
1235-
// The lock must be already held as the callback is executed
1236-
let rawlua = (*extra).raw_lua();
1237-
match (*upvalue).data {
1238-
Some(ref func) => (func.1)(rawlua, nargs, status),
1239-
None => Err(Error::CallbackDestructed),
1240-
}
1241-
})
1240+
callback_error_ext_yieldable(
1241+
state,
1242+
(*upvalue).extra.get(),
1243+
true,
1244+
|extra, nargs| {
1245+
// Lua ensures that `LUA_MINSTACK` stack spaces are available (after pushing
1246+
// arguments) The lock must be already held as the callback is
1247+
// executed
1248+
let rawlua = (*extra).raw_lua();
1249+
match (*upvalue).data {
1250+
Some(ref func) => (func.1)(rawlua, nargs, status),
1251+
None => Err(Error::CallbackDestructed),
1252+
}
1253+
},
1254+
true,
1255+
)
12421256
}
12431257

12441258
let state = self.state();

src/state/util.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ pub(crate) unsafe fn callback_error_ext_yieldable<F>(
168168
mut extra: *mut ExtraData,
169169
wrap_error: bool,
170170
f: F,
171-
in_callback_with_continuation: bool,
171+
#[cfg(feature = "luau")] _in_callback_with_continuation: bool,
172+
#[cfg(not(feature = "luau"))] in_callback_with_continuation: bool,
172173
) -> c_int
173174
where
174175
F: FnOnce(*mut ExtraData, c_int) -> Result<c_int>,

0 commit comments

Comments
 (0)