-
Notifications
You must be signed in to change notification settings - Fork 193
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
Destructuring assignment frequently becomes useless when paired with other features #202
Comments
This is the same as writing if true
{:a, :b} = {a: "Hello", b: "World"} Scoping in lua says that any variables introduced in a block are only available in that and nested blocks below. So when the if statement is left they are longer there. Because assigning and losing the variables isn't useful, I decided to break the rules. I added support for hoisting variable
I didn't add it for destructing though, so it's a bug. Could you explain more about how you think destructing assignment becomes useless? |
Here's an example from one of my own scripts, with a constant spliced in:
This would seem like an example in which I wouldn't have to worry about a hidden block, as the for loop is in a list comprehension. However, the product still isolates the list in a block so it does nothing and I end up with However, if I split it up into separate lines:
It works just fine. |
Ah, interesting. That's definitely a bug. Got any others? |
No, not really. Probably any bit of syntax that requires its own block will have a leading destructuring assessment drop its values in a soon to be terminated block. |
closing this in favor of #391 as it more accurately describes the specific issue |
Just an example:
Results in
nil nil
. Obviously the expressiveness of MoonScript allows this to be easily rewritten in a more effective way, but the behavior is difficult to debug without examination of the product.The text was updated successfully, but these errors were encountered: