[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: FORLOOP question
- From: Roberto Ierusalimschy <roberto@...>
- Date: Sun, 1 Mar 2015 17:19:19 -0300
> > 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?
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.)