rescript-compiler icon indicating copy to clipboard operation
rescript-compiler copied to clipboard

rescript convert: incorrect conversion of function keyword

Open cknitt opened this issue 2 years ago • 1 comments

The following code example is from jscomp/stdlib-406/list.ml, but the same issue occurs in many places in the OCaml stdlib code and prevents successful conversion from OCaml syntax to ReScript syntax.

rescript convert converts

let rec mem x = function
  | [] -> false
  | a :: l -> compare a x = 0 || mem x l

to

let rec mem = (x, x) =>
  switch x {
  | list{} => false
  | list{a, ...l} => compare(a, x) == 0 || mem(x, l)
  }

instead of something like

let rec mem = (x, param) =>
  switch param {
  | list{} => false
  | list{a, ...l} => compare(a, x) == 0 || mem(x, l)
  }

cknitt avatar Aug 07 '23 07:08 cknitt

Yes need to rename the x before converting an anonymous function from .ml.

cristianoc avatar Aug 07 '23 08:08 cristianoc