@@ -916,7 +916,7 @@ inline std::optional<int> try_call_newindex_extensible(lua_State* L, const char*
916916
917917 const Options options = get_class_options (L, -2 );
918918 if (! options.test (allowOverridingMethods))
919- luaL_error (L, " immutable member '%s'" , key);
919+ raise_lua_error (L, " immutable member '%s'" , key);
920920
921921 rawset_super_method (L, origClassTableIndex, key); // Stack: ..., candidate_ct
922922 lua_pop (L, 1 ); // Stack: ...
@@ -991,7 +991,7 @@ inline std::optional<int> try_call_newindex_extensible(lua_State* L, const char*
991991
992992 const Options options = get_class_options (L, -2 );
993993 if (! options.test (allowOverridingMethods))
994- luaL_error (L, " immutable member '%s'" , key);
994+ raise_lua_error (L, " immutable member '%s'" , key);
995995
996996 rawset_super_method (L, -2 , key); // Stack: ..., candidate_ct
997997 lua_pop (L, 1 ); // Stack: ...
@@ -1134,7 +1134,7 @@ inline int newindex_metamethod(lua_State* L)
11341134 // Try in the property set table on the current class first.
11351135 lua_rawgetp_x (L, -1 , getPropsetKey ()); // Stack: mt, propset table (ps) | nil
11361136 if (! lua_istable (L, -1 ))
1137- luaL_error (L, " no member named '%s'" , key);
1137+ raise_lua_error (L, " no member named '%s'" , key);
11381138
11391139 lua_pushvalue (L, 2 ); // Stack: mt, ps, field name
11401140 lua_rawget (L, -2 ); // Stack: mt, ps, setter | nil
@@ -1213,7 +1213,7 @@ inline int newindex_metamethod(lua_State* L)
12131213 }
12141214
12151215 lua_pop (L, 1 ); // Stack: -
1216- luaL_error (L, " no writable member '%s'" , key);
1216+ raise_lua_error (L, " no writable member '%s'" , key);
12171217 return 0 ;
12181218}
12191219
@@ -1234,7 +1234,7 @@ inline int newindex_metamethod_simple(lua_State* L)
12341234 const char * key = lua_tostring (L, 2 );
12351235
12361236 if (! lua_istable (L, lua_upvalueindex (1 )))
1237- luaL_error (L, " no writable member '%s'" , key);
1237+ raise_lua_error (L, " no writable member '%s'" , key);
12381238
12391239 lua_pushvalue (L, 2 ); // Stack: key
12401240 lua_rawget (L, lua_upvalueindex (1 )); // Stack: setter | nil
@@ -1258,7 +1258,7 @@ inline int newindex_metamethod_simple(lua_State* L)
12581258 const char * key = lua_tostring (L, 2 );
12591259
12601260 if (! lua_istable (L, lua_upvalueindex (1 )))
1261- luaL_error (L, " no writable member '%s'" , key);
1261+ raise_lua_error (L, " no writable member '%s'" , key);
12621262
12631263 lua_pushvalue (L, 2 ); // Stack: key
12641264 lua_rawget (L, lua_upvalueindex (1 )); // Stack: setter | nil
@@ -1270,7 +1270,7 @@ inline int newindex_metamethod_simple(lua_State* L)
12701270 return 0 ;
12711271 }
12721272
1273- luaL_error (L, " no writable member '%s'" , key);
1273+ raise_lua_error (L, " no writable member '%s'" , key);
12741274 }
12751275 }
12761276
@@ -1281,7 +1281,7 @@ inline int newindex_metamethod_simple(lua_State* L)
12811281
12821282 lua_rawgetp_x (L, -1 , getPropsetKey ()); // Stack: mt, ps | nil
12831283 if (! lua_istable (L, -1 ))
1284- luaL_error (L, " no member named '%s'" , key);
1284+ raise_lua_error (L, " no member named '%s'" , key);
12851285
12861286 lua_pushvalue (L, 2 ); // Stack: mt, ps, key
12871287 lua_rawget (L, -2 ); // Stack: mt, ps, setter | nil
@@ -1297,7 +1297,7 @@ inline int newindex_metamethod_simple(lua_State* L)
12971297 return 0 ;
12981298 }
12991299
1300- luaL_error (L, " no writable member '%s'" , key);
1300+ raise_lua_error (L, " no writable member '%s'" , key);
13011301 return 0 ;
13021302}
13031303
@@ -2123,7 +2123,8 @@ inline int try_overload_functions(lua_State* L)
21232123 }
21242124 lua_concat (L, nerrors * 2 + 1 );
21252125
2126- lua_error_x (L); // throw error message just built
2126+ const char * message = lua_tostring (L, -1 );
2127+ raise_lua_error (L, " %s" , message ? message : " " );
21272128}
21282129
21292130// =================================================================================================
0 commit comments