You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you declare objects which contain values which are arrays declared on multiple lines, the way whitespace is interpreted is very inconsistent and leads to subtle bugs.
I'm trying to represent the following object in Javascript:
var myObject = {
foo: {
bar: {
baz: ["hey"]
},
quux: "yo"
}
};
The following code in CoffeeScript compiles as expected:
But depending on how far over you indent the final square-bracket (there are 9 possible legal positions in this case) you get one of three different compilation outputs: the correct one, one where 'quux' is at the same level as 'foo', and one where 'quux' is not included in the object at all!
If you declare objects which contain values which are arrays declared on multiple lines, the way whitespace is interpreted is very inconsistent and leads to subtle bugs.
I'm trying to represent the following object in Javascript:
The following code in CoffeeScript compiles as expected:
But depending on how far over you indent the final square-bracket (there are 9 possible legal positions in this case) you get one of three different compilation outputs: the correct one, one where 'quux' is at the same level as 'foo', and one where 'quux' is not included in the object at all!
Here's the most pathological one:
compiles to
I would say that the expected behaviour should be that all 9 valid positions of the final square bracket should result in the same, correct compile :)
Thanks!
The text was updated successfully, but these errors were encountered: