Skip to content

Commit

Permalink
Fix parenthesization of fat arrow body
Browse files Browse the repository at this point in the history
Second half of #1582
  • Loading branch information
edemaine committed Nov 6, 2024
1 parent b6ae938 commit 7cc702d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 1 addition & 3 deletions source/parser.hera
Original file line number Diff line number Diff line change
Expand Up @@ -820,9 +820,7 @@ FatArrowBody
# NOTE: Skip expressionized statements, so they get braced instead
!EOS !( _? ExpressionizedStatement ) NonPipelineExpression:exp !TrailingDeclaration !TrailingPipe !TrailingPostfix !SemicolonDelimiter ->
// Ensure object literal is wrapped in parens
if (exp.type === "ObjectExpression") {
exp = makeLeftHandSideExpression(exp)
}
exp = makeExpressionStatement(exp)
const expressions = [["", exp]]
return {
type: "BlockStatement",
Expand Down
8 changes: 8 additions & 0 deletions test/object.civet
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@ describe "object", ->
({} as object)
"""

testCase """
function returning empty literal with suffix
---
=> {} as object
---
() =>( {} as object)
"""

testCase """
comma-separated literals
---
Expand Down

0 comments on commit 7cc702d

Please sign in to comment.