Skip to content

Commit

Permalink
Allow newline before ...rest parameter
Browse files Browse the repository at this point in the history
Partial fix to #760
  • Loading branch information
edemaine committed Oct 2, 2023
1 parent 589c43f commit eae5332
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 1 deletion.
2 changes: 1 addition & 1 deletion source/parser.hera
Original file line number Diff line number Diff line change
Expand Up @@ -1243,7 +1243,7 @@ NonEmptyParameters

# https://262.ecma-international.org/#prod-FunctionRestParameter
FunctionRestParameter
BindingRestElement:id TypeSuffix? ParameterElementDelimiter ->
__ BindingRestElement:id TypeSuffix? ParameterElementDelimiter ->
return {
type: "FunctionRestParameter",
children: $0,
Expand Down
64 changes: 64 additions & 0 deletions test/function.civet
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,70 @@ describe "function", ->
}
"""

describe "indented parameters", ->
testCase """
mixed
---
(
a, b
c, d
) => null
---
(
a, b,
c, d
) => null
"""

testCase """
...rest
---
foo := (
x
...rest
) -> null
---
function foo(
x,
...rest
) { return null }
"""

testCase """
rest...
---
foo := (
x
rest...
) -> null
---
function foo(
x,
...rest
) { return null }
"""

// TODO: wrong indentation of }s
testCase """
indented with types
---
function f<T>(
t:
item: T
u:
item: T
)
---
function f<T>(
t: {
item: T
},
u: {
item: T
}
){}
"""

describe "implicit returns", ->
testCase """
basic
Expand Down

0 comments on commit eae5332

Please sign in to comment.