[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Bug in hook(luaV_finishOp:OP_LE)?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 7 Apr 2015 12:43:20 -0300
> > [...]
> >
> > it has different result when call or not call 'lua_yield' in 'hook' fun, i
> > think there is a bug in when finish execution of an opcode(OP_LE)
> > interrupted by an yield.
> >
> > [...]
> > ......
> >
> > in func luaV_finishOp, i think it is necessary to invert result when both
> > R(B) and R(C) has no meta method 'TM_LE':
> > if (op == OP_LE && /* "<=" using "<" instead? */
> > ttisnil(luaT_gettmbyobj(L, base + GETARG_B(inst), TM_LE)) &&
> > ttisnil(luaT_gettmbyobj(L, base + GETARG_C(inst), TM_LE)))
> > res = !res; /* invert result */
>
> Many thanks for the detailed report. We will have a look into it.
Bug indeed. You do not need C code to produce it:
t1 = setmetatable({x=1},
{__le = function (a,b) coroutine.yield("yield"); return a.x <= b.x end})
t2 = {x=2}
co = coroutine.wrap(function (a,b) return a <= b end)
print(co(t2,t1)) --> yield
print(co()) --> true (should be false)
-- Roberto