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

Cannot read property 'superCalled' of undefined #8848

Closed
warent opened this issue Jun 30, 2017 · 8 comments · Fixed by #9348
Closed

Cannot read property 'superCalled' of undefined #8848

warent opened this issue Jun 30, 2017 · 8 comments · Fixed by #9348
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 rule Relates to ESLint's core rules

Comments

@warent
Copy link

warent commented Jun 30, 2017

Tell us about your environment

  • ESLint Version:
    ^3.8.1
  • Node Version:
    7.6.0
  • npm Version:
    4.1.2

What parser (default, Babel-ESLint, etc.) are you using?
"babel-eslint": "^7.0.0",
"eslint": "^3.8.1",
"eslint-config-react-app": "^0.6.2",
"eslint-plugin-flowtype": "^2.21.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.10.0"

Please show your full configuration:

{
  "extends": "react-app",
  "rules": {
    "semi": "warn",
    "no-mixed-spaces-and-tabs": "warn",
    "space-before-blocks": "warn",
    "space-unary-ops": "warn",
    "space-in-parens": "warn",
    "semi-spacing": "warn",
    "indent": ["warn", 2],
    "quotes": ["warn", "single"],
    "no-duplicate-imports": "warn",
    "jsx-quotes": ["warn", "prefer-double"],
    "react/jsx-curly-spacing": [2, "always"],
    "constructor-super": "warn",
    "prefer-spread": "warn",
    "no-var": "warn",
    "no-trailing-spaces": "warn",
    "object-curly-spacing": ["warn", "always"],
    "import/order": ["warn", { "groups": ["builtin", "external", "internal", "parent", "sibling", "index"], "newlines-between": "always" }],
    "no-multiple-empty-lines": ["warn", { "max": 1, "maxEOF": 1 }],
    "import/no-webpack-loader-syntax": "warn"
  },
  "globals": {
    "chrome": true
  }
}

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

class Extender {}
class BugProof extends Extender {

  constructor(props) {
    super(props);

    try {
      let arr = [];
      for (let a of arr) {

      }
    } catch (err) {

    }
  }
  
}

What did you expect to happen?
It shouldn't give any error

What actually happened? Please include the actual, raw output from ESLint.
screen shot 2017-06-30 at 9 15 18 am

file: 'bug.js'
severity: 'Error'
message: 'Parsing error: Unexpected token

  19 |   
  20 | 
> 21 | 
     | ^'
at: '21,1'
source: 'eslint'

The location of the "Parsing error: Unexpected token" will change depending on the last line edited.

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Jun 30, 2017
@warent warent changed the title Cannot read property 'superCall' of undefined Cannot read property 'superCalled' of undefined Jun 30, 2017
@kaicataldo
Copy link
Member

I haven't been able to reproduce, but whoever is looking into this should start with the no-this-before-super rule.

@kaicataldo kaicataldo added bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules and removed triage An ESLint team member will look at this issue soon labels Jun 30, 2017
@warent
Copy link
Author

warent commented Jun 30, 2017

Please note that the error goes away when the for loop is altered:

class Extender {}
class BugProof extends Extender {

  constructor(props) {
    super(props);

    try {
      for (let i = 0; i < 1; i++) {

      }
    } catch (err) {

    }
  }
}

If we keep the for..of loop, the error will also go away by one of the following:

  • Removing the extends
  • Removing the try..catch

@kaicataldo kaicataldo added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jun 30, 2017
@kaicataldo
Copy link
Member

kaicataldo commented Jun 30, 2017

I can recreate this with the latest version of ESLint with the above code and this minimal config:

{
    "env": {
      "es6": true
    },
    "rules": {
      "no-this-before-super": "error"
    }
}

@aladdin-add
Copy link
Member

aladdin-add commented Jun 30, 2017

@kaicataldo I find the error similar error seems occur in rule constructor-super: https://github.com/eslint/eslint/blob/master/lib/rules/constructor-super.js#L132

        function isCalledInSomePath(segment) {
            return segment.reachable && segInfoMap[segment.id].calledInSomePaths;
        }

segInfoMap[segment.id] sometimes can be undefined.

@not-an-aardvark
Copy link
Member

It's possible that this is a bug in the core code path analysis logic.

@gyandeeps
Copy link
Member

@mysticatea Any insight on this?

@mysticatea
Copy link
Member

Oh, I'm sorry, I had overlooked this issue.
I will take a look.

@mysticatea
Copy link
Member

It looks a bug in code path analysis. If ForInStatement#right is the first location which can throw a reference error in the outer try block, it has generated wrong code path. I need more investigation.

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Mar 27, 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 Mar 27, 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 rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants