reasonml / reason

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

Change operator precedence to be left biased. #2685

Open SanderSpies opened 1 year ago

SanderSpies commented 1 year ago

Make &, &&, |, ||, ++, and :: operators left associative.

The tradeoff here is between JS and OCaml.

Here’s the precedence list of JS: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#table

and here of OCaml: https://v2.ocaml.org/api/Ocaml_operators.html

The important difference here is:

&, &&, |, ||, ^, :: right associative in OCaml (and current ReasonML default) &, &&, |, ||, + left associative in JS. :: is obviously not present in JS and I decided to make that left associative as well as it “feels” more correct here.

See also: https://github.com/reasonml/reason/issues/2672