Skip to content
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
2 changes: 2 additions & 0 deletions formatTest/unit_tests/expected_output/bucklescript.re
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,5 @@ let d = {
"a": fun arg1 arg2 => arg1 + arg2
}
};

let a = {"/foo": 10};
2 changes: 2 additions & 0 deletions formatTest/unit_tests/input/bucklescript.re
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ let b = {"nested": {"objs": {"are": {"nice": "<3"}}}};
let c = {"a": a, "b": b, "func": fun a => a##c#=(func 10)};

let d = {"a": a2, "b": b , "func": fun a => {"a": (fun arg1 arg2 => arg1 + arg2)}};

let a = {"/foo": 10};
20 changes: 10 additions & 10 deletions src/reason_pprint_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4656,13 +4656,13 @@ class printer ()= object(self:'self)

method unparseRecord ?withStringKeys:(withStringKeys=false) ?allowPunning:(allowPunning=true) l eo =
let quote = (atom "\"") in
let maybeQuoteFirstElem l =
if withStringKeys then
(match l with
| fst::rest -> quote::fst::quote::rest
| _ -> l
)
else l
let maybeQuoteFirstElem fst rest =
if withStringKeys then (match fst.txt with
| Lident s -> quote::(atom s)::quote::rest
| Ldot _ | Lapply _ -> assert false
)
else
(self#longident_loc fst)::rest
in
let makeRow (li, e) appendComma shouldPun =
let comma = atom "," in
Expand All @@ -4675,13 +4675,13 @@ class printer ()= object(self:'self)
match e.pexp_desc with
(* Punning *)
| Pexp_ident {txt} when li.txt = txt && shouldPun && allowPunning ->
makeList (maybeQuoteFirstElem ((self#longident_loc li)::(if appendComma then [comma] else [])))
makeList (maybeQuoteFirstElem li (if appendComma then [comma] else []))
| _ ->
let (argsList, return) = self#curriedPatternsAndReturnVal e in (
match (argsList, return.pexp_desc) with
| ([], _) ->
let appTerms = self#unparseExprApplicationItems e in
let upToColon = makeList (maybeQuoteFirstElem [self#longident_loc li; atom ":"]) in
let upToColon = makeList (maybeQuoteFirstElem li [atom ":"]) in
let labelExpr =
formatAttachmentApplication
applicationFinalWrapping
Expand All @@ -4692,7 +4692,7 @@ class printer ()= object(self:'self)
else
labelExpr
| (firstArg::tl, _) ->
let upToColon = makeList (maybeQuoteFirstElem [self#longident_loc li; atom ":"]) in
let upToColon = makeList (maybeQuoteFirstElem li [atom ":"]) in
let returnedAppTerms = self#unparseExprApplicationItems return in
let labelExpr =
(self#wrapCurriedFunctionBinding ~attachTo:upToColon "fun" firstArg tl returnedAppTerms) in
Expand Down