-
Notifications
You must be signed in to change notification settings - Fork 156
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
Strange output for x = a.b.c: d #1072
Comments
What's happening here is that the x = a.b.{c: d} That's an object slice, and it's correctly compiling to what you see produced. Personally, I do think that this is pretty confusing to people who aren't expecting it, and I don't see anything in tests or the docs that suggest that this particular interaction is intended, so I'm inclined to agree that this should be a compiler error instead. Note to future self (or someone else fixing this): |
So in the future, this will throw syntax error? |
Probably, unless someone talks me out of it, and assuming I or someone else gets around to making it so. |
If any character deserves to be an exception to be allowed to be a part of an identifier, without quotes, it should be The reason is pragmatic, as So if it comes to me, I would opt for |
That's a pretty reasonable proposal. I want to be cautious about adding little inconsistencies like that, so I'd like to take a little longer to think it over, but you've made some good points. In terms of the implementation, there's still a bug in the brace insertion logic in the lexer that needs fixing, which is separate from hacking |
Going back to my proposal for a moment: one place, where it might be ambiguous, is property shorthand |
Yes, agreed. There's also the weird case of |
:O Interesting, I didn't know that |
|
|
|
hey, what about a little optimization for the |
@rhendric I think the reason for x = {a: 1, b: {c: 2}}
y = {...x} # => same as x
x.a = 5 # => y.a is still 1
x.b.c = 4 # => y.b.c is 4 It might be implemented because of compatibility reasons, however it seems an accurate call to exclude it from documentation. |
@ceremcem AFAIK there is no built-in deep cloning features in LS or any of the ancestor languages (JS, CS, Coco), there's only an undocumented deep comparison @determin1st While we're at it, we could do like Babel is doing and take |
@pepkin88 |
@determin1st Speed depends on the engine implementation. My current browser shows that Object.assign is only 9% slower than your import$$ and native spread being the slowest, while the table below shows how much native spread is crushing on Chrome 70. |
@pepkin88 okay, checkout another How do livescript detect that there is no |
@determin1st Yeah, looks good. Yes, it's doing it at runtime, as you said doing it at compile time requires some flags, so without that no code pruning opportunity there. |
Compiling following code:
produces this:
Where I would expect something like this:
...or a proper exception. Is this a bug or something expected?
The text was updated successfully, but these errors were encountered: