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

Wrong error message: SyntaxError: Cannot read property 'type' of undefined (0:0) #9226

Closed
ups-ishii opened this issue Sep 18, 2020 · 3 comments
Assignees
Labels
lang:javascript Issues affecting JS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency type:bug Issues identifying ugly output, or a defect in the program

Comments

@ups-ishii
Copy link

Environments:

  • Prettier Version: 2.1.2
  • Running Prettier via: CLI
  • Runtime: Node.js v12.16.1
  • Operating System: macOS

Steps to reproduce:

cat <<_EOF > sample.js
const p = {
  set name(){}
};
_EOF
npx prettier@2.1.2 sample.js

Expected behavior:

SyntaxError: setter must have exactly one formal parameter (2:3) is expected.

  • npx prettier@1.18.2 sample.js
sample.js[error] sample.js: SyntaxError: setter must have exactly one formal parameter (2:3)
[error]   1 | const p = {
[error] > 2 |   set name(){}
[error]     |   ^
[error]   3 | };
[error]   4 |

Actual behavior:

  • npx prettier@2.1.2 sample.js
sample.js[error] sample.js: SyntaxError: Cannot read property 'type' of undefined (0:0)
[error]   1 | const p = {
[error]   2 |   set name(){}
[error]   3 | };

FYI
It looks babel/parser throws right error but Prettier fails to parse the babel/parser error. may be.

  • npx @babel/parser sample.js
setter must have exactly one formal parameter (2:2)

Thank you

@fisker fisker self-assigned this Sep 18, 2020
@fisker fisker added javascript Pull requests that update Javascript code type:bug Issues identifying ugly output, or a defect in the program labels Sep 18, 2020
@fisker
Copy link
Member

fisker commented Sep 18, 2020

Upstream bug, tracked babel/babel#12074

@thorn0 thorn0 added lang:javascript Issues affecting JS scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency and removed javascript Pull requests that update Javascript code labels Sep 20, 2020
@fisker
Copy link
Member

fisker commented Oct 20, 2020

This is fixed by #9408

@fisker fisker closed this as completed Oct 20, 2020
@ups-ishii
Copy link
Author

ups-ishii commented Oct 20, 2020

Thank you very much!

@github-actions github-actions bot added the locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. label Jan 19, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lang:javascript Issues affecting JS locked-due-to-inactivity Please open a new issue and fill out the template instead of commenting. scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

3 participants