Re: [BUG] coroutine.resume() returns inaccurate error messages

  • From: Mike Pall <mike-1208@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 17 Aug 2012 21:37:36 +0200

agentzh wrote:
> The output from LuaJIT is a little confusing:
>     c1 status:        normal
>     resume c1:        false   cannot resume running coroutine
>     resume c2:        true
> We can see that the "c1" thread is in "normal" status according to the
> coroutine.status() call, but the error message returned by
> coroutine.resume() says "c1" is a "running coroutine" instead.

I could buy the consistency argument, but IMHO the proper error
message really is 'cannot resume running coroutine', because the
coroutine c1 *is* running (one stack level below).

> The output from the standard Lua 5.1.4 interpreter is very consistent here:
>     c1 status:        normal
>     resume c1:        false   cannot resume normal coroutine
>     resume c2:        true
> Maybe LuaJIT 2.0 beta10 requires fixing here?

The Lua error is really a side-effect of the way it generates the
error message and IMHO it's misleading.

Try resuming c2 instead of c1 and you'll get 'cannot resume
running coroutine'. Why should there be a difference? LuaJIT gives
the same error for both.


Other related posts: