lua-users home
lua-l archive

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


I look forward to the flexibility comparisons.

On Wed, Apr 8, 2015 at 9:03 PM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> > > [...]
> > >
> > > 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. [...]

The bug is confirmed, but the fix is not. Any of the values can be a
constant, and therefore "base + GETARG_X" is not the correct way to
access it.

This code was written in the change from 5.1 to 5.2. In 5.1, order
metamethods were only called when the values had the same type and
the same metamethod. Therefore, they could not be constants (as
numbers and strings do not call order metamethods) and, if one was
nil, the other had to be nil, too. Later, we added more flexibility
to the comparisons but did not fix this function.

-- Roberto