Skip to content

Commit 6c240a8

Browse files
committed
Fix formatting edge-cases when formatting ReScript -> ReScript
Configure the parser to pass forPrinter:true when parsing / printing ReScript. This fixes issues where e.g. Some((1, 2)) get misprinted to Some(1,2) etc. Relevant bug reports: - rescript-lang/syntax#274 - rescript-lang/syntax#265
1 parent eadc6e4 commit 6c240a8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

jscomp/refmt/jsoo_refmt_main.ml

+4-2
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,11 @@ module Compile = struct
583583
Pprintast.structure Format.str_formatter structure;
584584
Format.flush_str_formatter ()
585585
| (Res, Res) ->
586-
(* Basically pretty printing *)
586+
(* Essentially pretty printing.
587+
* IMPORTANT: we need forPrinter:true when parsing code here,
588+
* otherwise we will loose some information for the ReScript printer *)
587589
let (structure, comments) =
588-
ResDriver.parse_implementation ~forPrinter:false ~sourcefile:filename ~src
590+
ResDriver.parse_implementation ~forPrinter:true ~sourcefile:filename ~src
589591
in
590592
Res_printer.printImplementation ~width:80 structure ~comments
591593
| (OCaml, OCaml) -> src

0 commit comments

Comments
 (0)