From b191218993900eb95aba1062c07e1b93d1373ebe Mon Sep 17 00:00:00 2001 From: qwreey Date: Sat, 9 Nov 2024 12:44:55 +0000 Subject: [PATCH] Throw out of index error in struct:field method (#243) --- crates/lune-std-ffi/src/c/struct_info.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/lune-std-ffi/src/c/struct_info.rs b/crates/lune-std-ffi/src/c/struct_info.rs index f97f89a..b175a07 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")) }, ); }