| 274 | |
| 275 | |
| 276 | static void trymt (lua_State *L, const char *mtname) { |
| 277 | lua_settop(L, 2); /* back to the original arguments */ |
| 278 | if (lua_type(L, 2) == LUA_TSTRING || !luaL_getmetafield(L, 2, mtname)) |
| 279 | luaL_error(L, "attempt to %s a '%s' with a '%s'", mtname + 2, |
| 280 | luaL_typename(L, -2), luaL_typename(L, -1)); |
| 281 | lua_insert(L, -3); /* put metamethod before arguments */ |
| 282 | lua_call(L, 2, 1); /* call metamethod */ |
| 283 | } |
| 284 | |
| 285 | |
| 286 | static int arith (lua_State *L, int op, const char *mtname) { |
no test coverage detected