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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Unexpected error thrown #13322

Closed
1 task
fisker opened this issue May 17, 2021 · 3 comments 路 Fixed by #13326
Closed
1 task

[Bug]: Unexpected error thrown #13322

fisker opened this issue May 17, 2021 · 3 comments 路 Fixed by #13326
Assignees
Labels
i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser

Comments

@fisker
Copy link
Contributor

fisker commented May 17, 2021

馃捇

  • Would you like to work on a fix?

How are you using Babel?

Programmatic API (babel.transform, babel.parse)

Input code

require("@babel/parser").parse('<div propA={[ key: value ]} propsB={(a: b)} />', {sourceType: 'module', errorRecovery:true, plugins: ['jsx', 'typescript'], tokens: true})
Uncaught TypeError: Cannot read property 'type' of undefined
    at babel7CompatTokens (<CWD>\node_modules\@babel\parser\lib\index.js:12432:17)
    at Object.parseTopLevel (<CWD>\node_modules\@babel\parser\lib\index.js:12466:44)
    at Object.parse (<CWD>\node_modules\@babel\parser\lib\index.js:14186:10)
    at Object.parse (<CWD>\node_modules\@babel\parser\lib\index.js:7925:18)
    at Object.parse (<CWD>\node_modules\@babel\parser\lib\index.js:14238:38)

Configuration file name

No response

Configuration

No response

Current and expected behavior

Should throw SyntaxError

Environment

Babel version: 7.14.2

Possible solution

No response

Additional context

Prettier PR prettier/prettier#10898

@babel-bot
Copy link
Collaborator

Hey @fisker! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@fisker
Copy link
Contributor Author

fisker commented May 17, 2021

This code was added in https://github.com/babel/babel/pull/12221/files, but didn't test on errorRecovery:true mode.

@fedeci
Copy link
Member

fedeci commented May 17, 2021

On astexplorer which is using v7.13.9 it works correctly, so the regression may have not been introduced in #12221


edit: v7.14.1 works fine, v7.14.2 is failing probably due to #13256

@JLHwung JLHwung self-assigned this May 17, 2021
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Aug 17, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants