Skip to content

Simplify and correct PermittedJumps computation #18165

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

Merged
merged 6 commits into from
Sep 8, 2017

Conversation

amcasey
Copy link
Member

@amcasey amcasey commented Aug 30, 2017

  1. It was looking at the parent which wasn't guaranteed to be in the extracted range.
  2. It was checking direct, rather than indirect containment - apparently to avoid applying the rules to certain expressions (which can't contain jumps anyway, unless they're in anonymous functions, in which case they're fine).

Fixes #18144

Note that this is built on top of #18164. They're independent, but git would report a merge conflict between their newly introduced tests. Reviewers can ignore amcasey@e8ff205.

@msftclas
Copy link

@amcasey,
Thanks for your contribution as a Microsoft full-time employee or intern. You do not need to sign a CLA.
Thanks,
Microsoft Pull Request Bot


return errors;

function visit(node: Node) {
function visit(node: Node, permittedJumps: PermittedJumps) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is rather a style comment. we have used passing functions as arguments to forEach, forEachChild, map, etc..

Copy link
Member Author

@amcasey amcasey Sep 7, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm not sure I understand this comment. Were you saying that it was more conventional before, when we just captured a variable and reset it after each recursive call?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. I'll just revert 57906fe.

When the return type is void, there's no `returnValueProperty`, but that
doesn't mean we don't need a `return` at the call site.

Fixes microsoft#18140.
1. It was looking at the parent which wasn't guaranteed to be in the
extracted range.
2. It was checking direct, rather than indirect containment - apparently
to avoid applying the rules to certain expressions (which can't contain
jumps anyway, unless they're in anonymous functions, in which case
they're fine).

Fixes microsoft#18144
@amcasey amcasey merged commit deefb01 into microsoft:master Sep 8, 2017
@amcasey amcasey deleted the GH18144 branch September 8, 2017 17:50
amcasey added a commit to amcasey/TypeScript that referenced this pull request Sep 16, 2017
Simplify and correct PermittedJumps computation

(cherry picked from commit deefb01)
amcasey added a commit to amcasey/TypeScript that referenced this pull request Sep 18, 2017
Simplify and correct PermittedJumps computation

(cherry picked from commit deefb01)
break;
}

switch (node.kind) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function now switches on node.kind four different times, is there any way it could be simplified or broken up?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand your concern. The switches don't appear to overlap (I didn't check exhaustively) and different kinds are interesting at different times. I imagine that parts of the method could be split out into helpers but I don't see much advantage to doing so.

amcasey added a commit to amcasey/TypeScript that referenced this pull request Sep 20, 2017
Simplify and correct PermittedJumps computation

(cherry picked from commit deefb01)
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants