-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Parser fail on errorRecovery mode #12074
Copy link
Copy link
Closed
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: parser
Description
Bug Report
- I would like to work on a fix!
Current behavior
node -p "require('@babel/parser').parse('const a = {set name(){}}', {errorRecovery: true})"
if (method.kind === "set" && method.params[method.params.length - 1].type === "RestElement") {
^
TypeError: Cannot read property 'type' of undefined
at Parser.checkGetterSetterParams (@babel\parser\lib\index.js:10792:74)
at Parser.parseObjectMethod (@babel\parser\lib\index.js:10800:12)
at Parser.parseObjPropValue (@babel\parser\lib\index.js:10841:23)
at Parser.parsePropertyDefinition (@babel\parser\lib\index.js:10772:10)
at Parser.parseObjectLike (@babel\parser\lib\index.js:10664:25)
at Parser.parseExprAtom (@babel\parser\lib\index.js:10198:23)
at Parser.parseExprSubscripts (@babel\parser\lib\index.js:9844:23)
at Parser.parseUpdate (@babel\parser\lib\index.js:9824:21)
at Parser.parseMaybeUnary (@babel\parser\lib\index.js:9813:17)
at Parser.parseExprOps (@babel\parser\lib\index.js:9683:23)With errorRecovery: true parser didn't throw syntax error
Input Code
const a = {set name(){}}Expected behavior
Should throw a SyntaxError or continue parse.
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
N/A
Environment
- Babel version(s): 7.11.5
- Node/npm version: Node.js 12
- OS: Windows 10
- Monorepo: no
- How you are using Babel: parser api
Possible Solution
N/A
Additional context
Context: prettier/prettier#9226
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: parser