Re: Bug with table.insert

  • From: Matthias Moninger <m.moninger.h@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 31 Mar 2015 19:32:30 +0200

I was already thinking that it might do that when Jit is enabled,
however I haven't quite figured out how i could tell it now that it
will return a value, could you maybe give some insight on that.

On Tue, Mar 31, 2015 at 7:29 PM, Mike Pall <mike-1503@xxxxxxxxxx> wrote:
> Matthias Moninger wrote:
>> So GMod lua uses a modified variant of table.insert where it would
>> return the index of newly inserted element by lua_pushnumber(L, i)
>
> Changing the semantics of core builtins is a bad idea.
>
>> However running that code below has somehow undefined behavior by that:
>
> Well, the JIT compiler doesn't know anything about that change and
> will happily return nothing from table.insert(), if it's compiled.
>
> Changing only the interpreter part of LuaJIT without keeping the
> JIT compiler in sync is a really, really bad idea.
>
>> -- print(i) -- Uncommenting this will prevent somehow i becoming nil
>
> That's because print() aborts a trace (in v2.0) and the loop is
> interpreted as a consequence.
>
> --Mike
>



-- 
Best regards / Mit freundlichen Grüßen,
Matthias Moninger

Other related posts: