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

Fix: broken code path of direct nested loops (fixes #8248) #8274

Merged
merged 2 commits into from
Mar 17, 2017

Conversation

mysticatea
Copy link
Member

@mysticatea mysticatea commented Mar 17, 2017

What is the purpose of this pull request? (put an "X" next to item)

[X] Bug fix (template)

Fixes #8248.

What changes did you make? (Give an overview)

This PR fixes the broken code path about the direct nest of same kind loops.
The fix is below. Other diffs are for tests.

@@ -512,13 +512,8 @@ function processCodePathToExit(analyzer, node) {
             break;
     }
 
-    /*
-     * Skip updating the current segment to avoid creating useless segments if
-     * the node type is the same as the parent node type.
-     */
-    if (!dontForward && (!node.parent || node.type !== node.parent.type)) {
-
-        // Emits onCodePathSegmentStart events if updated.
+    // Emits onCodePathSegmentStart events if updated.
+    if (!dontForward) {
         forwardCurrentToHead(analyzer, node);
     }
     debug.dumpState(node, state, true);

I had been trying to optimize the code path, but it has been breaking.
I just removed the broken optimizing code.

As a result, the code path about the direct nest of same kind loops is recovered.
For example:

while (a)
    while (b)
        foo()
Before: outer loop's looping path is lacking.

image

After: OK.

image


Is there anything you'd like reviewers to focus on?

http://www.webgraphviz.com/ is useful to confirm test's code path with DOT diagrams.

@mysticatea mysticatea added accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features labels Mar 17, 2017
@mention-bot
Copy link

@mysticatea, thanks for your PR! By analyzing the history of the files in this pull request, we identified @kaicataldo, @platinumazure and @gyandeeps to be potential reviewers.

@eslintbot
Copy link

LGTM

@eslintbot
Copy link

LGTM

Copy link
Member

@not-an-aardvark not-an-aardvark left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@not-an-aardvark not-an-aardvark merged commit 85f74ca into master Mar 17, 2017
@not-an-aardvark not-an-aardvark deleted the code-path/fix-nested-same-loop branch April 28, 2017 17:29
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 2018
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Feb 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

constructor-super throws when it encounters nested loops
5 participants