Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #705 #802

Merged
merged 1 commit into from
Nov 10, 2023
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
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") {
STRd6 marked this conversation as resolved.
Show resolved Hide resolved
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