Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.
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
6 changes: 3 additions & 3 deletions src/res_core.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1576,7 +1576,7 @@ and parseTernaryExpr leftOperand p =
| _ ->
leftOperand

and parseEs6ArrowExpression ?parameters p =
and parseEs6ArrowExpression ?context ?parameters p =
let startPos = p.Parser.startPos in
Parser.leaveBreadcrumb p Grammar.Es6ArrowExpr;
let parameters = match parameters with
Expand All @@ -1592,7 +1592,7 @@ and parseEs6ArrowExpression ?parameters p =
in
Parser.expect EqualGreater p;
let body =
let expr = parseExpr p in
let expr = parseExpr ?context p in
match returnType with
| Some typ ->
Ast_helper.Exp.constraint_
Expand Down Expand Up @@ -2108,7 +2108,7 @@ and parseOperandExpr ~context p =
if (context != WhenExpr) &&
isEs6ArrowExpression ~inTernary:(context=TernaryTrueBranchExpr) p
then
parseEs6ArrowExpression p
parseEs6ArrowExpression ~context p
else
parseUnaryExpr p
in
Expand Down
3 changes: 3 additions & 0 deletions tests/printer/expr/__snapshots__/render.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4037,6 +4037,9 @@ a =>

let x = @attrOnTernary (truth ? true : false)
let x = @attrOnCondition truth ? true : false

x ? y => () : onChange
let y = <input value onChange={x ? _ => () : onChange} />
"
`;

Expand Down
3 changes: 3 additions & 0 deletions tests/printer/expr/expected/ternary.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,6 @@ a => a ? aasdasdasdasdasdasdaaasdasdasdasdasdasdasdasdasdasdasdasdasdaaaaaaaaa :

let x = @attrOnTernary (truth ? true : false)
let x = @attrOnCondition truth ? true : false

x ? y => () : onChange
let y = <input value onChange={x ? _ => () : onChange} />
3 changes: 3 additions & 0 deletions tests/printer/expr/ternary.res
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,6 @@ a => a ? aasdasdasdasdasdasdaaasdasdasdasdasdasdasdasdasdasdasdasdasdaaaaaaaaa :

let x = @attrOnTernary (truth ? true : false)
let x = @attrOnCondition truth ? true : false

x ? y => () : onChange
let y = <input value onChange={x ? _ => () : onChange} />