Skip to content

Commit

Permalink
Merge pull request #802 from DanielXMoore/705
Browse files Browse the repository at this point in the history
Fix #705
  • Loading branch information
STRd6 authored Nov 10, 2023
2 parents f39bf83 + 62959d9 commit 38b658b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion source/parser.hera
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,12 @@ TrailingDeclaration
# https://262.ecma-international.org/#prod-ConciseBody
FatArrowBody
# If same-line single expression, avoid wrapping in braces
!EOS NonPipelinePostfixedExpression:exp !TrailingDeclaration !SemicolonDelimiter -> exp
!EOS NonPipelinePostfixedExpression:exp !TrailingDeclaration !SemicolonDelimiter ->
// Ensure object literal is wrapped in parens
if (exp.type === "ObjectExpression") {
return makeLeftHandSideExpression(exp)
}
return exp
# Otherwise, wrap block body in braces and insert returns
NoCommaBracedOrEmptyBlock

Expand Down
8 changes: 8 additions & 0 deletions test/function.civet
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,14 @@ describe "function", ->
}
"""

testCase """
arrow function with object literal
---
() => a: b
---
() =>( {a: b})
"""

testCase """
void fat arrow
---
Expand Down

0 comments on commit 38b658b

Please sign in to comment.