reasonml / reason

Simple, fast & type safe code that leverages the JavaScript & OCaml ecosystems
http://reasonml.github.io
MIT License
10.09k stars 424 forks source link

Reason 3.6.2: refmt can break parentheses in some cases #2636

Closed bryphe closed 1 year ago

bryphe commented 3 years ago

Just saw there was a new release of @opam/reason at version 3.6.2 - figured I'd give it a test run!

It looks like there is a regression with refmt - in some cases, the parentheses can be removed too aggressively from an expression, for example:

fun
| [] => None
| [(child: node), ...rest] => ...

Gets refmt'd to:

fun
| [] => None
| [child: None, ...rest] => ...

Which then becomes a compilation error:

File "src/Components/Tabs.re", line 24, characters 18-19:
24 |           | [child: node, ..._] when i == index =>
                       ^
Error: Unclosed "(" (opened line 20, column 38)

Hit this in trying to upgrade Onivim here: https://github.com/onivim/oni2/pull/2688

jchavarri commented 3 years ago

I ran into a very similar issue, not sure if the same but tracking here in case it helps.

In v3.7.0 from opam.

let foo =
  fun
  | (hey: baz) => ();

gets compiled into:

let foo =
  fun
  | hey: baz => ();
davesnx commented 1 year ago

This is fixed in the master branch, we will release it under 3.9.0