Skip to content

Fixed generic for stopping prematurely on 'false' value#139

Open
funmaker wants to merge 1 commit into
kyren:masterfrom
funmaker:generic-for-fix
Open

Fixed generic for stopping prematurely on 'false' value#139
funmaker wants to merge 1 commit into
kyren:masterfrom
funmaker:generic-for-fix

Conversation

@funmaker
Copy link
Copy Markdown

https://www.lua.org/pil/7.2.html

After this initialization step, the for calls the iterator function with two arguments: the invariant state and the control variable. (Notice that, for the for structure, the invariant state has no meaning at all. It only gets this value from the initialization step and passes it when it calls the iterator function.) Then the for assigns the values returned by the iterator function to variables declared by its variable list. If the first value returned (the one assigned to the control variable) is nil, the loop terminates. Otherwise, the for executes its body and calls the iteration function again, repeating the process.

The current implementation stops on both nil and false. This PR fixes this bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant