Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for loop semantics to Lua 5.4 #170

Closed
hugomg opened this issue Feb 4, 2020 · 0 comments · Fixed by #172
Closed

Update for loop semantics to Lua 5.4 #170

hugomg opened this issue Feb 4, 2020 · 0 comments · Fixed by #172
Labels
bug Something isn't working

Comments

@hugomg
Copy link
Member

hugomg commented Feb 4, 2020

Pallene's implementation of the for loop is not equivalent to Lua's in some corner cases:

The first is when the loop step is zero:

  • Lua 5.3 loops infinitely if start ≥ limit, and skips the loop if start < limit
  • Pallene loops infinitely if start > limit, and skips the loop if start ≤ limit.
  • Lua 5.4 raises a runtime error.

The second is when the loop variable overflows:

  • In Lua 5.3 and Pallene, the internal loop variable can overflow, causing an infinite loop.
  • In Lua 5.4, a loop count is computed before the start of the loop, using integer division.
@hugomg hugomg added the bug Something isn't working label Feb 4, 2020
hugomg added a commit that referenced this issue Feb 5, 2020
hugomg added a commit that referenced this issue Feb 5, 2020
hugomg added a commit that referenced this issue Feb 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant