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

Logical nullish assignment (??=) throwing error #3560

Closed
sothix opened this issue Aug 14, 2021 · 3 comments · Fixed by #3563
Closed

Logical nullish assignment (??=) throwing error #3560

sothix opened this issue Aug 14, 2021 · 3 comments · Fixed by #3563

Comments

@sothix
Copy link

sothix commented Aug 14, 2021

This code seems to be breaking latest NPM version: 2.13.1 with the following error:

let a = [1,2];
a[0] ??= 0;

Uncaught TypeError: Cannot read property 'paren' of undefined

@sothix sothix changed the title nullish coalescing operator (??=) throwing error Logical nullish assignment (??=) throwing error Aug 14, 2021
@bespokebob
Copy link

bespokebob commented Aug 19, 2021

I'm seeing this on just a regular nullish expression on both 2.13.0 and 2.13.1. The source line of the error is

if (!right.paren && (right.id === "||" || right.id === "&&")) {

@jugglinmike
Copy link
Member

A fix is under review here: gh-3563

JSHint does not currently support "logical assignment" operator nor will it following the acceptance of that patch. The bug in this case is the crash; JSHint is expected to report a syntax error for the provided input. Please refer to gh-3544 to follow the implementation of logical assignment.

@bespokebob
Copy link

I was seeing this in the codemirror editor, using the jshint integration, while typing a nullish coalescing expression. So it's probably the same issue - I was in the middle of typing an (incomplete) expression and jshint crashed instead of returning a syntax error for the incomplete line.

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

Successfully merging a pull request may close this issue.

3 participants