diff --git a/crates/lune-std-ffi/src/c/struct_info.rs b/crates/lune-std-ffi/src/c/struct_info.rs index f97f89a0..b175a07e 100644 --- a/crates/lune-std-ffi/src/c/struct_info.rs +++ b/crates/lune-std-ffi/src/c/struct_info.rs @@ -206,7 +206,9 @@ impl LuaUserData for CStructInfo { "field", |lua, (this, field_index): (LuaAnyUserData, usize)| { let field_table = get_field_table(lua, &this)?; - field_table.raw_get::<_, LuaAnyUserData>(field_index + 1) + field_table + .raw_get::<_, Option>(field_index + 1)? + .ok_or_else(|| LuaError::external("Out of index")) }, ); }