Permalink
Browse files

Fix object literal using at index

  • Loading branch information...
1 parent 5160781 commit 2be362d56b537953eb2148e6a952c7301b4507b7 @tricknotes tricknotes committed Jul 28, 2011
View
@@ -199,7 +199,12 @@ class Builder
'~': (n) -> "~#{@build n.left()}"
'typeof': (n) -> "typeof #{@build n.left()}"
- 'index': (n) -> "#{@build n.left()}[#{@build n.right()}]"
+ 'index': (n) ->
+ right = @build n.right()
+ if _.any(n.children, (child) -> child.typeName() == 'object_init' and child.children.length > 1)
+ right = "{#{right}}"
+ "#{@build n.left()}[#{right}]"
+
'throw': (n) -> "throw #{@build n.exception}"
'!': (n) ->
@@ -0,0 +1,6 @@
+o = {}
+o[{
+ a: 1
+ b: 2
+}] = 3
+o[c: 4] = 5
@@ -0,0 +1,5 @@
+var o = {}
+
+o[{a: 1, b: 2}] = 3
+
+o[{c: 4}] = 5

0 comments on commit 2be362d

Please sign in to comment.