Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/coffee-script/nodes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/nodes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ exports.Splat = class Splat extends Base
assigns: (name) ->
@name.assigns name

compileToFragments: (o) ->
compileNode: (o) ->
@name.compileToFragments o
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this get LEVEL_OP too?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case no, since in CS1 splats are not operators, but are instead handled by Arr and Assign.


unwrap: -> @name
Expand Down
27 changes: 24 additions & 3 deletions test/arrays.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ test "array splat expansions with assignments", ->
eq 4, b
arrayEq [0,1,2,3,4], list


test "mixed shorthand objects in array lists", ->

arr = [
a:1
'b'
Expand All @@ -58,7 +56,6 @@ test "mixed shorthand objects in array lists", ->
eq arr[2].b, 1
eq arr[3], 'b'


test "array splats with nested arrays", ->
nonce = {}
a = [nonce]
Expand All @@ -70,6 +67,30 @@ test "array splats with nested arrays", ->
list = [1, 2, a...]
arrayEq list, [1, 2, [nonce]]

test "#4260: splat after existential operator soak", ->
a = {b: [3]}
foo = (a) -> [a]
arrayEq [a?.b...], [3]
arrayEq [c?.b ? []...], []
arrayEq foo(a?.b...), [3]
arrayEq foo(c?.b ? []...), [undefined]
e = yes
f = null
arrayEq [(a if e)?.b...], [3]
arrayEq [(a if f)?.b ? []...], []
arrayEq foo((a if e)?.b...), [3]
arrayEq foo((a if f)?.b ? []...), [undefined]

test "#1349: trailing if after splat", ->
a = [3]
b = yes
c = null
foo = (a) -> [a]
arrayEq [a if b...], [3]
arrayEq [(a if c) ? []...], []
arrayEq foo((a if b)...), [3]
arrayEq foo((a if c) ? []...), [undefined]

test "#1274: `[] = a()` compiles to `false` instead of `a()`", ->
a = false
fn = -> a = true
Expand Down