diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-01-13 14:17:32 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-01-13 14:17:32 -0200 |
commit | 0c7de97d47074b82dd08e67443e78dcee1241277 (patch) | |
tree | bba645a8e0624f9a95ffdee79d2bd6b54df463ec /ldo.c | |
parent | 900b7d4514a29e9214f15213a81e2ee00bd482c3 (diff) | |
download | lua-0c7de97d47074b82dd08e67443e78dcee1241277.tar.gz lua-0c7de97d47074b82dd08e67443e78dcee1241277.tar.bz2 lua-0c7de97d47074b82dd08e67443e78dcee1241277.zip |
correct error message when yielding from outside a coroutine
Diffstat (limited to 'ldo.c')
-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"); |