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

[a >>>= b] = c #1325

Closed
satyr opened this issue May 3, 2011 · 7 comments
Closed

[a >>>= b] = c #1325

satyr opened this issue May 3, 2011 · 7 comments
Labels

Comments

@satyr
Copy link
Collaborator

satyr commented May 3, 2011

$ coffee -bpe '[a >>>= b] = c'
var b;
b = c.a;
@sparecycles
Copy link
Contributor

seems like this bug (?) works for

 [a ???= b] = c 

for any arithmetic ??? (or nothing).

@michaelficarra
Copy link
Collaborator

@Adam-F: Yeah, arbitrary expressions (like assignment and compound assignment) should not be allowed on the left side of destructuring assignment, only identifiers and other destructuring constructs.

@jashkenas jashkenas removed this from the as soon as a patch is available milestone Jun 2, 2015
@GeoffreyBooth
Copy link
Collaborator

In CS2 this compiles to:

var a;

[a >>>= b] = c;

Which is invalid JavaScript, but probably not worth our time for the compiler to catch as opposed to the runtime.

@lydell
Copy link
Collaborator

lydell commented Apr 26, 2017

The compiler should not emit invalid JavaScript.

@lydell lydell reopened this Apr 26, 2017
@GeoffreyBooth
Copy link
Collaborator

That’s not quite true. The compiler should not emit invalid JavaScript for valid CoffeeScript, but we’re not trying to catch all potentially catchable errors at compile time. We don’t validate potentially invalid regular expressions, for example:

new RegExp("(?<=\\s)(?<!\\:\\s)#.*?\\{.*?\\}","gm");

That compiles to JavaScript, and the runtime throws Invalid regular expression.

See this comment. It’s not worth the added complexity and performance hit for the compiler to catch all possible edge cases, especially ones that will be caught by the runtime anyway.

@lydell
Copy link
Collaborator

lydell commented Apr 27, 2017

Unicode and regex are completely different beasts. This case is perfectly possible to fix with way less complexity. I’m fine if you close this with your go-to “This doesn’t affect many people. PRs welcome”, but not with your previous comment.

@GeoffreyBooth
Copy link
Collaborator

Okay. If someone would like to fix this, please be our guest.

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

No branches or pull requests

6 participants