summaryrefslogtreecommitdiff
path: root/ldo.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-01-13 14:17:32 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2010-01-13 14:17:32 -0200
commit0c7de97d47074b82dd08e67443e78dcee1241277 (patch)
treebba645a8e0624f9a95ffdee79d2bd6b54df463ec /ldo.c
parent900b7d4514a29e9214f15213a81e2ee00bd482c3 (diff)
downloadlua-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.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/ldo.c b/ldo.c
index af4ee5e7..178e12e6 100644
--- a/ldo.c
+++ b/ldo.c
@@ -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");