Add __type to Error's userdata metatable.

Close #585
This commit is contained in:
Alex Orlenko
2025-05-27 01:31:54 +01:00
parent 13395e9c3d
commit 76a8f8cc71
3 changed files with 21 additions and 6 deletions
+5 -1
View File
@@ -349,7 +349,11 @@ pub(crate) unsafe fn init_error_registry(state: *mut ffi::lua_State) -> Result<(
state,
Some(|state| {
ffi::lua_pushcfunction(state, error_tostring);
rawset_field(state, -2, "__tostring")
ffi::lua_setfield(state, -2, cstr!("__tostring"));
// This is mostly for Luau typeof() function
ffi::lua_pushstring(state, cstr!("error"));
ffi::lua_setfield(state, -2, cstr!("__type"));
}),
)?;