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

Allow 'in' to terminate expressions in for fixes #5203 #5219

Merged
merged 1 commit into from
Jul 27, 2018

Conversation

rhuanjl
Copy link
Collaborator

@rhuanjl rhuanjl commented May 23, 2018

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

@akroshg akroshg requested a review from aneeshdk May 23, 2018 19:10
@akroshg
Copy link
Contributor

akroshg commented May 23, 2018

@rhuanjl the fix seems correct to me. I'll let @aneeshdk to comment/approve this. Thanks for making the change.

@Cellule
Copy link
Contributor

Cellule commented Jun 1, 2018

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");
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Collaborator Author

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.

@rhuanjl
Copy link
Collaborator Author

rhuanjl commented Jun 2, 2018

I've:

  1. Added some functionality tests cases in response to @MSLaguana's points above
  2. Updated latest

@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 () => "" the parser has not reached the "in" token and is possibly still on the quotes - I'm afraid I'm not sure how/why this happens.

@rhuanjl
Copy link
Collaborator Author

rhuanjl commented Jun 14, 2018

Please let me know if I should do anything further on this.

@@ -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);
Copy link
Contributor

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?

Copy link
Contributor

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?

Copy link
Collaborator Author

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

@akroshg
Copy link
Contributor

akroshg commented Jun 14, 2018

LGTM - @aneeshdk can you do the review and validate?
Should this be rebase to release/1.10?

@Cellule
Copy link
Contributor

Cellule commented Jun 14, 2018

I think it should target release/1.10 yeah

@aneeshdk
Copy link
Contributor

LGTM. release/1.10 sounds good.

assert.isTrue(false, "shouldn't reach here");
}
}
testGen(gen3, ['d'], 1);
Copy link
Contributor

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?

Copy link
Collaborator Author

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?

@aneeshdk aneeshdk assigned rhuanjl and unassigned aneeshdk Jun 15, 2018
@rhuanjl rhuanjl changed the base branch from master to release/1.10 June 23, 2018 13:03
@rhuanjl rhuanjl force-pushed the fixYieldIn branch 2 times, most recently from 0ed24a7 to 8410b0d Compare June 23, 2018 13:26
@rhuanjl
Copy link
Collaborator Author

rhuanjl commented Jun 23, 2018

I've:

  1. changed to target 1.10
  2. updated to latest
  3. renamed the inTerminate parameter to fAllowIn per review above

I have not:

  1. Added any more tests - @aneeshdk unsure what additional test case you were asking for
  2. Fixed the Lambda returning a string case mentioned by @Cellule : for (var b = () => "" in []) Possibly should open a separate issue for this - there's something else going on here and I can't work it out - after evaluating the lambda the parser seems to think that the next token is a double quote, not the in.

Sorry that I was a bit slow to respond to feedback on this.

@rhuanjl
Copy link
Collaborator Author

rhuanjl commented Jun 28, 2018

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.

@dilijev
Copy link
Contributor

dilijev commented Jun 30, 2018

@rhuanjl did you make all the updates you wanted to make after #5380 landed?

@dilijev dilijev assigned aneeshdk and unassigned rhuanjl Jun 30, 2018
@rhuanjl
Copy link
Collaborator Author

rhuanjl commented Jun 30, 2018

Yes I think this is good to land now.

@aneeshdk
Copy link
Contributor

LGTM

@aneeshdk aneeshdk removed their assignment Jul 12, 2018
@rhuanjl
Copy link
Collaborator Author

rhuanjl commented Jul 20, 2018

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?

@dilijev
Copy link
Contributor

dilijev commented Jul 27, 2018

@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.

@chakrabot chakrabot merged commit c212f22 into chakra-core:release/1.10 Jul 27, 2018
chakrabot pushed a commit that referenced this pull request Jul 27, 2018
#5203

Merge pull request #5219 from rhuanjl:fixYieldIn

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
chakrabot pushed a commit that referenced this pull request Jul 27, 2018
…ons in for fixes #5203

Merge pull request #5219 from rhuanjl:fixYieldIn

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
@rhuanjl rhuanjl deleted the fixYieldIn branch July 27, 2018 22:08
@rhuanjl
Copy link
Collaborator Author

rhuanjl commented Jul 27, 2018

Thanks for merging this.

@dilijev
Copy link
Contributor

dilijev commented Jul 31, 2018

@rhuanjl thanks for the contribution!

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

Successfully merging this pull request may close these issues.

7 participants