-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Loop behavior altered by continue
and return
#954
Comments
And
Syntax error. |
Good points both. Do you have an alternative solution in mind? |
Remove this implicit transformation. (I'm glad Coco did.) |
I'm afraid that this inconsistency is a necessary part of the implicit transformation. As long as we have functions-in-loops that close over their variables, we'll have to have this as well. The current situation with pure statements like |
I have an alternative alternative solution: remove Failing that, just document the issue and leave things as they are. |
Thanks for wrapping all of this up in #959, Trevor. Closing this ticket in favor of that one. |
Following up issue 948:
On the current master,
gives you
but if you add a
continue
orreturn
statement anywhere in the loop, the behavior is radically changed, e.g.:gives you
as would the same code with, say,
return if false
in place ofcontinue
.Let's look at the compiled output without the
continue
/return
:Currently, the whole
_fn
thing isn't done if there's acontinue
orreturn
anywhere in the loop.One solution would be to replace
_fn(i);
withretVal = _fn(i); retVal ? return retVal[0] : 0;
, and then compilecontinue
toreturn
,return
toreturn [void 0];
, andreturn value
toreturn [value]
. (Edit: This proposal wasn't tested and needs more work; see satyr's comment below.)The text was updated successfully, but these errors were encountered: