@@ -185,6 +185,12 @@ test "destructuring assignment with splats", ->
185185 arrayEq [b,c,d], y
186186 eq e, z
187187
188+ # Should not trigger implicit call, e.g. rest ... => rest(...)
189+ [x ,y ... ,z ] = [a,b,c,d,e]
190+ eq a, x
191+ arrayEq [b,c,d], y
192+ eq e, z
193+
188194test " deep destructuring assignment with splats" , ->
189195 a = {}; b = {}; c = {}; d = {}; e = {}; f = {}; g = {}; h = {}; i = {}
190196 [u , [v , w ... , x ], y ... , z ] = [a, [b, c, d, e], f, g, h, i]
@@ -229,6 +235,11 @@ test "destructuring assignment with objects and splats", ->
229235 eq a, y
230236 arrayEq [b,c,d], z
231237
238+ # Should not trigger implicit call, e.g. rest ... => rest(...)
239+ {a : b : [y , z ... ]} = obj
240+ eq a, y
241+ arrayEq [b,c,d], z
242+
232243test " destructuring assignment against an expression" , ->
233244 a = {}; b = {}
234245 [y , z ] = if true then [a, b] else [b, a]
@@ -263,6 +274,15 @@ test "destructuring assignment with splats and default values", ->
263274 eq b, 1
264275 deepEqual d, {}
265276
277+ # Should not trigger implicit call, e.g. rest ... => rest(...)
278+ {
279+ a : {b } = c
280+ d ...
281+ } = obj
282+
283+ eq b, 1
284+ deepEqual d, {}
285+
266286test " destructuring assignment with splat with default value" , ->
267287 obj = {}
268288 c = {val : 1 }
@@ -276,6 +296,18 @@ test "destructuring assignment with multiple splats in different objects", ->
276296 deepEqual a, val : 1
277297 deepEqual b, val : 2
278298
299+ # Should not trigger implicit call, e.g. rest ... => rest(...)
300+ {
301+ a : {
302+ a ...
303+ }
304+ b : {
305+ b ...
306+ }
307+ } = obj
308+ deepEqual a, val : 1
309+ deepEqual b, val : 2
310+
279311test " destructuring assignment with dynamic keys and splats" , ->
280312 i = 0
281313 foo = -> ++ i
@@ -299,6 +331,15 @@ test "destructuring assignment with objects and splats: Babel tests", ->
299331 n = { x, y, z... }
300332 deepEqual n, { x : 1 , y : 2 , a : 3 , b : 4 }
301333
334+ # Should not trigger implicit call, e.g. rest ... => rest(...)
335+ { x , y , z ... } = { x : 1 , y : 2 , a : 3 , b : 4 }
336+ eq x, 1
337+ eq y, 2
338+ deepEqual z, { a : 3 , b : 4 }
339+
340+ n = { x, y, z ... }
341+ deepEqual n, { x : 1 , y : 2 , a : 3 , b : 4 }
342+
302343test " deep destructuring assignment with objects: ES2015" , ->
303344 a1 = {}; b1 = {}; c1 = {}; d1 = {}
304345 obj = {
@@ -320,6 +361,13 @@ test "deep destructuring assignment with objects: ES2015", ->
320361 eq bb, b1
321362 eq r2 .b2 , obj .b2
322363
364+ # Should not trigger implicit call, e.g. rest ... => rest(...)
365+ {a : w , b : {c : {d : {b1 : bb , r1 ... }}}, r2 ... } = obj
366+ eq r1 .e , c1
367+ eq r2 .b , undefined
368+ eq bb, b1
369+ eq r2 .b2 , obj .b2
370+
323371test " deep destructuring assignment with defaults: ES2015" , ->
324372 obj =
325373 b : { c : 1 , baz : ' qux' }
@@ -343,16 +391,55 @@ test "deep destructuring assignment with defaults: ES2015", ->
343391 eq hello, ' world'
344392 deepEqual h, some : ' prop'
345393
394+ # Should not trigger implicit call, e.g. rest ... => rest(...)
395+ {
396+ a ...
397+ b : {
398+ c,
399+ d ...
400+ }
401+ e : {
402+ f : hello
403+ g : {
404+ h ...
405+ } = i
406+ } = j
407+ } = obj
408+
409+ deepEqual a, foo : ' bar'
410+ eq c, 1
411+ deepEqual d, baz : ' qux'
412+ eq hello, ' world'
413+ deepEqual h, some : ' prop'
414+
346415test " object spread properties: ES2015" , ->
347416 obj = {a : 1 , b : 2 , c : 3 , d : 4 , e : 5 }
348417 obj2 = {obj... , c : 9 }
349418 eq obj2 .c , 9
350419 eq obj .a , obj2 .a
351420
421+ # Should not trigger implicit call, e.g. rest ... => rest(...)
422+ obj2 = {
423+ obj ...
424+ c : 9
425+ }
426+ eq obj2 .c , 9
427+ eq obj .a , obj2 .a
428+
352429 obj2 = {obj... , a : 8 , c : 9 , obj... }
353430 eq obj2 .c , 3
354431 eq obj .a , obj2 .a
355432
433+ # Should not trigger implicit call, e.g. rest ... => rest(...)
434+ obj2 = {
435+ obj ...
436+ a : 8
437+ c : 9
438+ obj ...
439+ }
440+ eq obj2 .c , 3
441+ eq obj .a , obj2 .a
442+
356443 obj3 = {obj... , b : 7 , g : {obj2... , c : 1 }}
357444 eq obj3 .g .c , 1
358445 eq obj3 .b , 7
@@ -370,10 +457,42 @@ test "object spread properties: ES2015", ->
370457 eq obj4 .f .g , 5
371458 deepEqual obj4 .f , obj .c .f
372459
460+ # Should not trigger implicit call, e.g. rest ... => rest(...)
461+ (({
462+ a
463+ b
464+ r ...
465+ }) ->
466+ eq 1 , a
467+ deepEqual r, {c : 3 , d : 44 , e : 55 }
468+ ) {
469+ obj2 ...
470+ d : 44
471+ e : 55
472+ }
473+
474+ # Should not trigger implicit call, e.g. rest ... => rest(...)
475+ obj4 = {
476+ a : 10
477+ obj .c ...
478+ }
479+ eq obj4 .a , 10
480+ eq obj4 .d , 3
481+ eq obj4 .f .g , 5
482+ deepEqual obj4 .f , obj .c .f
483+
373484 obj5 = {obj... , ((k ) -> {b : k})(99 )... }
374485 eq obj5 .b , 99
375486 deepEqual obj5 .c , obj .c
376487
488+ # Should not trigger implicit call, e.g. rest ... => rest(...)
489+ obj5 = {
490+ obj ...
491+ ((k ) -> {b : k})(99 ) ...
492+ }
493+ eq obj5 .b , 99
494+ deepEqual obj5 .c , obj .c
495+
377496 fn = -> {c : {d : 33 , e : 44 , f : {g : 55 }}}
378497 obj6 = {obj... , fn ()... }
379498 eq obj6 .c .d , 33
@@ -382,7 +501,16 @@ test "object spread properties: ES2015", ->
382501 obj7 = {obj... , fn ()... , {c : {d : 55 , e : 66 , f : {77 }}}... }
383502 eq obj7 .c .d , 55
384503 deepEqual obj6 .c , {d : 33 , e : 44 , f : {g : 55 }}
385-
504+
505+ # Should not trigger implicit call, e.g. rest ... => rest(...)
506+ obj7 = {
507+ obj ...
508+ fn () ...
509+ {c : {d : 55 , e : 66 , f : {77 }}} ...
510+ }
511+ eq obj7 .c .d , 55
512+ deepEqual obj6 .c , {d : 33 , e : 44 , f : {g : 55 }}
513+
386514 obj =
387515 a :
388516 b :
0 commit comments