lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


David Morris-Oliveros wrote:
> // the function been called has a deliberate error
> int result = lua_resume( L, 0 );
> [
> L->top - L->base = 5
> L->ci->top - L->base = 2
> result = LUA_ERRRUN
> ]

Well, maybe inspecting the slots of the top-most frame of
a dead coroutine is relying on undocumented behaviour. Apart
from its stack slots you'll find several strings from error
message generation lying around.

In this example there are 5-2 = 3 strings on the top of the
stack: the plain error message, the error message including
the source file/line and another copy of the latter.

But yes, breaking the assumption that L->ci->top >= L->top
could be called a bug. Mainly because it doesn't play well
with other API functions.

Simple fix: add the following line in ldo.c at the end of

    if (L->top > L->ci->top) L->ci->top = L->top;