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

Parser throws undefined when parsing HTML-Like comment #11769

Closed
1 task
fisker opened this issue Jul 1, 2020 · 4 comments · Fixed by #11774
Closed
1 task

Parser throws undefined when parsing HTML-Like comment #11769

fisker opened this issue Jul 1, 2020 · 4 comments · Fixed by #11774
Labels
i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@fisker
Copy link
Contributor

fisker commented Jul 1, 2020

Bug Report

  • I would like to work on a fix!

Properly not

Current behavior

When parsing HTML-Like comment with sourceType: 'module', the @babel/parser throws undefined.

Input Code

require('@babel/parser').parse('alert(<!--comment\n)', {plugins: ['jsx'], sourceType: 'module'})

Expected behavior

Should throw an error.

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

NaN

Environment

- Babel version(s): 7.10.4
- Node/npm version: [e.g. Node v14.4.0/npm v6.14.5]
- OS: Windows 10
- Monorepo: no
- How you are using Babel: api

Possible Solution

NaN

Additional context

PR on Prettier project prettier/prettier#8688

CI Log https://github.com/prettier/prettier/runs/825234580?check_suite_focus=true#step:7:1200

Expected error, Received: undefined

@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 fisker changed the title Parser throws undefined Parser throws undefined when parsing HTML-Like comment Jul 1, 2020
@fisker
Copy link
Contributor Author

fisker commented Jul 1, 2020

Maybe caused by #11722?

@fisker
Copy link
Contributor Author

fisker commented Jul 1, 2020

Local tested changing

https://github.com/babel/babel/pull/11722/files#diff-56fea09eea2de51b8291db400d2f69beR1175

to

-          throw this.expectOnePlugin(["jsx", "flow", "typescript"]);
+          this.expectOnePlugin(["jsx", "flow", "typescript"]);

Fixes this issue, but I think it's not right, if it's HTML-Like comment, it should not expect those plugins, and those plugins wouldn't help.

Maybe we need check sourceType there.

I'm not familiar with codebase, I'm not going to send PR.

@JLHwung
Copy link
Contributor

JLHwung commented Jul 1, 2020

@fisker Thanks for the detailed report and background digging. It helps a lot.

@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 Oct 1, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants