diff options
| -rw-r--r-- | ldo.c | 10 |
1 files changed, 7 insertions, 3 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldo.c,v 2.78 2009/12/17 12:28:57 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.79 2009/12/22 15:32:50 roberto Exp roberto $ |
| 3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -554,8 +554,12 @@ LUA_API int lua_yieldk (lua_State *L, int nresults, int ctx, lua_CFunction k) { | |||
| 554 | luai_userstateyield(L, nresults); | 554 | luai_userstateyield(L, nresults); |
| 555 | lua_lock(L); | 555 | lua_lock(L); |
| 556 | api_checknelems(L, nresults); | 556 | api_checknelems(L, nresults); |
| 557 | if (L->nny > 0) | 557 | if (L->nny > 0) { |
| 558 | luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); | 558 | if (L != G(L)->mainthread) |
| 559 | luaG_runerror(L, "attempt to yield across metamethod/C-call boundary"); | ||
| 560 | else | ||
| 561 | luaG_runerror(L, "attempt to yield from outside a coroutine"); | ||
| 562 | } | ||
| 559 | L->status = LUA_YIELD; | 563 | L->status = LUA_YIELD; |
| 560 | if (isLua(ci)) { /* inside a hook? */ | 564 | if (isLua(ci)) { /* inside a hook? */ |
| 561 | api_check(L, k == NULL, "hooks cannot continue after yielding"); | 565 | api_check(L, k == NULL, "hooks cannot continue after yielding"); |
