lua-users home
lua-l archive

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

> > In the FORLOOP implementation in lvm.c the index is updated as shown
> > below (and similarly for floating point):
> > 
> >                 setivalue(ra, idx);  /* update internal index... */
> >                 setivalue(ra + 3, idx);  /* ...and external index */
> > 
> > It seems that only the value needs to be updated - not the type, as
> > the type is already set by the FORPREP instruction. Is that correct?
> Yes.

Sorry... The "untyped" assignment to 'ra' is safe. The one to 'ra + 3'
(to the external index) is not; FORPREP does not set this value and,
moreover, the loop body can change it to any value. (The behavior is
undefined when the code does such changes, but Lua should not crash.)

-- Roberto