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

"Invalid left-hand side in assignment": incorrectly reported as SyntaxError #9487

Open
getify opened this Issue Feb 10, 2019 · 3 comments

Comments

Projects
None yet
4 participants
@getify
Copy link

getify commented Feb 10, 2019

Bug Report

Current Behavior
Code like 2++ or 3 = 2 result in a SyntaxError ("Invalid left-hand side assignment"), when they should be resulting in an error of type ReferenceError.

According to the spec, they are not invalid syntax, but are rather runtime errors. In fact, you could make the case the parser shouldn't error on them at all, but if it's going to error, it would be helpful if it was correctly labeled to be consistent with what is reported in Chrome devtools console, for instance.

Input Code

2++;
3 = 2;

Expected behavior/code
Either no parsing exception at all, or a ReferenceError reported.

Environment

  • Babylon version: 6.18.0
  • Node/npm version: Node 10.15.0
  • OS: OSX 10.14

Additional context/Screenshots

screen shot 2019-02-10 at 12 34 33 pm

@babel-bot

This comment has been minimized.

Copy link
Collaborator

babel-bot commented Feb 10, 2019

Hey @getify! 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.

@nicolo-ribaudo

This comment has been minimized.

Copy link
Member

nicolo-ribaudo commented Feb 10, 2019

According to your screenshot those aren't runtime errors: the functions aren't called.

@getify

This comment has been minimized.

Copy link
Author

getify commented Feb 10, 2019

Yes sorry I misspoke. This issue should stay focused on the wrong error type.


(edit)

FTR, my misstatement about "runtime" was that I was incorrectly confusing this in my head with the case of 3(), which is often thought of as being a compile-time syntax error, but it's actually a runtime TypeError. My bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment