-
Notifications
You must be signed in to change notification settings - Fork 1.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
Allow 'in' to terminate expressions in for fixes #5203 #5219
Conversation
I still get a syntax error with for (var b = () => "" in []) {
undefined;
} |
{ | ||
name : "yield is allowed before 'in' in a for loop control but not elsewhere bug issue #5203", | ||
body : function () { | ||
assert.doesNotThrow(function () { eval("function* gf() {for(var a = yield in {});}"); }, "Yield is allowed before 'in' in a for loop"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the correct interpretation of for(var a = yield 1 in {}) {…
? I think the only way for that to parse is as for( var a = (yield 1) in {})
, is that how it behaves with this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And going further afield, it looks like v8 parses for(var a = yield 'a' in {} in {a: 1})
as for(var a = (yield 'a') in ({} in {a:1}))
; does that work out here as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both of these work in that way - I'll compose some functionality tests.
I've:
@Cellule that case follows a different path in the Parser and would require a different fix notably it seems that after parsing the lambda expression |
Please let me know if I should do anything further on this. |
lib/Parser/Parse.h
Outdated
@@ -780,7 +780,7 @@ class Parser | |||
template<bool buildAST> ParseNodePtr ParseMemberList(LPCOLESTR pNameHint, uint32 *pHintLength, tokens declarationType = tkNone); | |||
template<bool buildAST> IdentPtr ParseSuper(bool fAllowCall); | |||
|
|||
bool IsTerminateToken(); | |||
bool IsTerminateToken(bool inTerminate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit : would it better to understand if this is called as tkInAsTerminate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just reuse the name fAllowIn?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've renamed it to fAllowIn
LGTM - @aneeshdk can you do the review and validate? |
I think it should target release/1.10 yeah |
LGTM. release/1.10 sounds good. |
test/es6/forInEdgeCases.js
Outdated
assert.isTrue(false, "shouldn't reach here"); | ||
} | ||
} | ||
testGen(gen3, ['d'], 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add a test case where a value is passed into the next call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm sorry I'm not sure what you're asking for.
The testGen function I'm using a the top uses an assertion to verify that the correct value is yielded - not sure what I should o beyond that?
0ed24a7
to
8410b0d
Compare
I've:
I have not:
Sorry that I was a bit slow to respond to feedback on this. |
This will need updating to be compatible with #5380 as they're touching the same code - there's some overlap both this and #5380 fix: for (var i = () => {} in {}); This also fixes for (var a = yield 'd' in {} in {a: 1}) Which #5380 does not fix. BUT #5380 fixes: for (var b = () => "" in []) Which this does not fix. I assume #5380 will land first then can update this to fit with it. |
of a for...in loop fixes chakra-core#5203.
Yes I think this is good to land now. |
LGTM |
Please let me know if there is anything further I need to do on this. Is it going to be merged? Or should I close it? |
@rhuanjl Apologies for letting this fall off my radar. You can leave it open. Right now we are re-evaluating which branch to merge this to. |
Thanks for merging this. |
@rhuanjl thanks for the contribution! |
Attempt at fixing issue #5203
Based on #5216
Not 100% sure I've got this right but it passes the mentioned cases and doesn't regress anything I'm aware of.
cc @zenparsing @akroshg