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

error-message: Maximum call stack size exceeded #915

Closed
fisker opened this issue Dec 4, 2020 · 3 comments · Fixed by #922
Closed

error-message: Maximum call stack size exceeded #915

fisker opened this issue Dec 4, 2020 · 3 comments · Fixed by #922
Labels

Comments

@fisker
Copy link
Collaborator

fisker commented Dec 4, 2020

When running on this code,

const a = undefined;
function b() {
  throw undefined;
}
RangeError: Maximum call stack size exceeded
Occurred while linting <CWD>\1.ts:1
    at findIdentifierValues (<CWD>\rules\error-message.js:32:24)
    at checkErrorMessage (<CWD>\rules\error-message.js:80:28)
    at checkErrorMessage (<CWD>\rules\error-message.js:82:4)
    at checkErrorMessage (<CWD>\rules\error-message.js:82:4)
    at checkErrorMessage (<CWD>\rules\error-message.js:82:4)
    at checkErrorMessage (<CWD>\rules\error-message.js:82:4)
    at checkErrorMessage (<CWD>\rules\error-message.js:82:4)
    at checkErrorMessage (<CWD>\rules\error-message.js:82:4)
    at checkErrorMessage (<CWD>\rules\error-message.js:82:4)
    at checkErrorMessage (<CWD>\rules\error-message.js:82:4) {
  currentNode: Node {
    type: 'Program',
    start: 0,
    end: 58,
    loc: SourceLocation { start: [Position], end: [Position] },
    range: [ 0, 57 ],
    body: [ [Node], [Node], [Node] ],
    sourceType: 'module',
    comments: [],
    tokens: [
      [Token], [Token], [Token],
      [Token], [Token], [Token],
      [Token], [Token], [Token],
      [Token], [Token], [Token],
      [Token], [Token], [Token]
    ],
    parent: null
  }
}

This is not a real-world code, but I don't know what's wrong yet.

Bug found during #914, file https://github.com/prettier/prettier/blob/master/tests/typescript/conformance/types/functions/functionImplementations.ts

@fisker fisker added the bug label Dec 4, 2020
@fisker
Copy link
Collaborator Author

fisker commented Dec 4, 2020

/* global x */
const a = x;
throw x;

This fails it too.

@fisker
Copy link
Collaborator Author

fisker commented Dec 7, 2020

@sindresorhus This rule is a little hard for me to understand, it suppose to check

Enforce passing a message value when throwing a built-in error

But the code tracking ThrowStatement, this make it hard to track the references, do you think we just check NewExpression?

const foo = new Error()

This should be a invalid case, even it didn't throw.

@sindresorhus
Copy link
Owner

But the code tracking ThrowStatement, this make it hard to track the references, do you think we just check NewExpression?

That does sound like a better way to do it.

This should be a invalid case, even it didn't throw.

👍🏻

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

Successfully merging a pull request may close this issue.

2 participants