lua-users home
lua-l archive

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


Thanks for the reference snippets, I know that I needed the Protect or
else the lua vm would crash sometimes (didn't dig into why this
happens) so it does have precedent. My only concern with going to the
general step like you show is that lots of libraries, especially c
libraries may use certain assumptions about the types of things it can
be compared against leading to errors instead of returning false (not
sure if you have run into this issue).

Thanks,
Nathan


On Thu, Jan 20, 2022 at 11:30 PM Flyer31 Test <flyer31@googlemail.com> wrote:
>
> PS: sorry I overlooked this in the existing / old "..." text, you can
> then comment out these lines:
> //      case LUA_VUSERDATA: {
> //        if (uvalue(t1) == uvalue(t2)) return 1;
> //        else if (L == NULL) return 0;
> //        tm = fasttm(L, uvalue(t1)->metatable, TM_EQ);
> //        if (tm == NULL)
> //          tm = fasttm(L, uvalue(t2)->metatable, TM_EQ);
> //        break;  /* will try TM */
> //      }
>
> (so mainly you just shift this block to the function start and do it
> also already, if only ONE of two operands is LUA_VUSERDATA).
>
> Further I needed a line change in function luaV_execute for the
> switch-case-block vmcase(OP_EQK):
> +       Protect(cond = luaV_equalobj(L, s2v(ra), rb));
> -        cond = luaV_equalobj(L, s2v(ra), rb);
>
> .. so I added this "Protect(...)" there - do not ask me why, I did not
> write a comment there... .