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

constructor-super throws when it encounters nested loops #8248

Closed
not-an-aardvark opened this issue Mar 14, 2017 · 2 comments · Fixed by singapore/lint-condo#244, #8274 or renovatebot/renovate#137 · May be fixed by iamhunter/teammates#4
Closed
Assignees
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

Comments

@not-an-aardvark
Copy link
Member

Tell us about your environment

  • ESLint Version: master
  • Node Version: 7.7.2
  • npm Version: 4.1.2

What parser (default, Babel-ESLint, etc.) are you using?

default

Please show your full configuration:

rules:
    constructor-super: error
parserOptions:
    ecmaVersion: 2015

What did you do? Please include the actual source code causing the issue.

class Foo extends Bar {
    constructor() {
        for (a in b) for (c in d);
    }
}

What did you expect to happen?

I expected ESLint to not crash.

What actually happened? Please include the actual, raw output from ESLint.

ESLint crashed.

TypeError: Cannot read property 'calledInSomePaths' of undefined
    at isCalledInSomePath (/path/to/eslint/lib/rules/constructor-super.js:132:63)
    at Array.some (native)
    at CodePath.funcInfo.codePath.traverseSegments.segment (/path/to/eslint/lib/rules/constructor-super.js:270:63)
    at CodePath.traverseSegments (/path/to/eslint/lib/code-path-analysis/code-path.js:208:30)
    at EventEmitter.onCodePathSegmentLoop (/path/to/eslint/lib/rules/constructor-super.js:263:35)
    at emitThree (events.js:116:13)
    at EventEmitter.emit (events.js:197:7)
    at CodePathAnalyzer.onLooped (/path/to/eslint/lib/code-path-analysis/code-path-analyzer.js:646:26)
    at makeLooped (/path/to/eslint/lib/code-path-analysis/code-path-state.js:191:15)
    at CodePathState.popLoopContext (/path/to/eslint/lib/code-path-analysis/code-path-state.js:1024:17)

It looks like when CodePath#traverseSegments is called, there is a segment where one of segment.prevSegments never triggered onCodePathSegmentStart. I'm not familiar with code path analysis, so I don't know whether this is a rule bug or a code path analysis bug in core.

@mysticatea, do you know where the issue might be coming from?

@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly rule Relates to ESLint's core rules labels Mar 14, 2017
@mysticatea
Copy link
Member

Oh, thank you for the report.
I'll investigate it.

@mysticatea
Copy link
Member

I found the code path is broken if the body of a loop is the same kind loop.
I will fix this later.

@mysticatea mysticatea self-assigned this Mar 14, 2017
@mysticatea mysticatea added core Relates to ESLint's core APIs and features and removed rule Relates to ESLint's core rules labels Mar 14, 2017
not-an-aardvark pushed a commit that referenced this issue Mar 17, 2017
* Fix: broken code path of direct nested loops (fixes #8248)

* Chore: remove a marker to grep
@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
2 participants