** Check whether object at given level has a close metamethod and raise ** an error if not. */
| 123 | ** an error if not. |
| 124 | */ |
| 125 | static void checkclosemth (lua_State *L, StkId level) { |
| 126 | const TValue *tm = luaT_gettmbyobj(L, s2v(level), TM_CLOSE); |
| 127 | if (ttisnil(tm)) { /* no metamethod? */ |
| 128 | int idx = cast_int(level - L->ci->func.p); /* variable index */ |
| 129 | const char *vname = luaG_findlocal(L, L->ci, idx, NULL); |
| 130 | if (vname == NULL) vname = "?"; |
| 131 | luaG_runerror(L, "variable '%s' got a non-closable value", vname); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | |
| 136 | /* |
no test coverage detected