Skip to content

Commit a091bb8

Browse files
helixbassGeoffreyBooth
authored andcommitted
AST: splat param location data (#5266)
* handle assignment to nested nontrailing splat * splat param location data
1 parent a6d4bf1 commit a091bb8

File tree

3 files changed

+78
-2
lines changed

3 files changed

+78
-2
lines changed

lib/coffeescript/nodes.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/nodes.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4234,7 +4234,7 @@ exports.Code = class Code extends Base
42344234
{name, value, splat} = param
42354235
if splat
42364236
new Splat name, lhs: yes, postfix: splat.postfix
4237-
.withLocationDataFrom name
4237+
.withLocationDataFrom param
42384238
else if value?
42394239
new Assign name, value, null, param: yes
42404240
.withLocationDataFrom locationData: mergeLocationData name.locationData, value.locationData

test/abstract_syntax_tree_location_data.coffee

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4556,6 +4556,82 @@ test "AST location data as expected for Code node", ->
45564556
line: 1
45574557
column: 2
45584558

4559+
testAstLocationData '''
4560+
(a...) ->
4561+
''',
4562+
type: 'FunctionExpression'
4563+
params: [
4564+
argument:
4565+
start: 1
4566+
end: 2
4567+
range: [1, 2]
4568+
loc:
4569+
start:
4570+
line: 1
4571+
column: 1
4572+
end:
4573+
line: 1
4574+
column: 2
4575+
start: 1
4576+
end: 5
4577+
range: [1, 5]
4578+
loc:
4579+
start:
4580+
line: 1
4581+
column: 1
4582+
end:
4583+
line: 1
4584+
column: 5
4585+
]
4586+
start: 0
4587+
end: 9
4588+
range: [0, 9]
4589+
loc:
4590+
start:
4591+
line: 1
4592+
column: 0
4593+
end:
4594+
line: 1
4595+
column: 9
4596+
4597+
testAstLocationData '''
4598+
(...a) ->
4599+
''',
4600+
type: 'FunctionExpression'
4601+
params: [
4602+
argument:
4603+
start: 4
4604+
end: 5
4605+
range: [4, 5]
4606+
loc:
4607+
start:
4608+
line: 1
4609+
column: 4
4610+
end:
4611+
line: 1
4612+
column: 5
4613+
start: 1
4614+
end: 5
4615+
range: [1, 5]
4616+
loc:
4617+
start:
4618+
line: 1
4619+
column: 1
4620+
end:
4621+
line: 1
4622+
column: 5
4623+
]
4624+
start: 0
4625+
end: 9
4626+
range: [0, 9]
4627+
loc:
4628+
start:
4629+
line: 1
4630+
column: 0
4631+
end:
4632+
line: 1
4633+
column: 9
4634+
45594635
test "AST location data as expected for Return node", ->
45604636
testAstLocationData 'return no',
45614637
type: 'ReturnStatement'

0 commit comments

Comments
 (0)