FA-90247 / Bytecode virtual machines / Member archive
Numeric for loop: last iteration dropped · case 02
for i = 1, 4 yields 1, 2, 3.
Case contract
Numeric for-loop preparation (Lua-style FORPREP/FORLOOP). A zero step is an error. With integer init and step, a float limit is floored for positive steps and ceiled for negative ones; the loop is skipped when init is already past the limit in the step direction; otherwise the iteration count (limit - init) // step is precomputed (for negative steps (init - limit) // -step) and the loop runs count + 1 times. Otherwise the loop uses floats and re-tests v <= limit (v >= limit for negative steps). Return at most the first 20 control values.
Why this case matters
Loop-preparation opcodes must precompute counts exactly to avoid off-by-one and overflow bugs.
One recorded failure
Sample boundary fixtureThis sample comes from the broken implementation of a controlled reproducer.
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: ascending integer loop | [1, 2, 3, 4] | [1, 2, 3, 4, 5] | Failed |
MEMBER ARCHIVE
The complete case is available to members.
This record includes three runnable implementations, regression fixtures, execution results, and source hashes.
Member access is invitation-based. Sign in with your invited account to inspect the sources.
Sign in to the archive ↗