reasonml / reason

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

Long refmt run time with a stack overflow on a file with a bunch of modules #2594

Open Lupus opened 4 years ago

Lupus commented 4 years ago

I've distilled my file down to the following snippet:

module M1 = {
  include X({
    let r = x => {z: s => s};
  });
  let f = (m, x) => x;
  let f_z = (m, x) => x;
  let g = {z: s => s};
  let u = s => {z: s => s};
};

module M6 = {
  include X({
    let r = x => {z: s => s};
  });
  let f = (m, x) => x;
  let f_z = (m, x) => x;
  let g = {z: s => s};
  let u = s => {z: s => s};
};

module M5 = {
  include X({
    let r = x => {z: s => s};
  });
  let f = (m, x) => x;
  let f_z = (m, x) => x;
  let g = {z: s => s};
  let u = s => {z: s => s};
};

module M4 = {
  include X({
    let r = x => {z: s => s};
  });
  let f = (m, x) => x;
  let f_z = (m, x) => x;
  let g = {z: s => s};
  let u = s => {z: s => s};
};

module M3 = {
  include X({
    let r = x => {z: s => s};
  });
  let f = (m, x) => x;
  let f_z = (m, x) => x;
  let g = {z: s => s};
  let u = s => {z: s => s};
};

module M2 = {
  include X({
    let r = x => {z: s => s};
  });
  let f = (m, x) => x;
  let f_z = (m, x) => x;
  let g = {z: s => s};
  let u = s => {z: s => s};
};

Which still demonstrates the problem:

$ time refmt --print=binary refmt-repro.re > /dev/null
Stack overflow

real    0m17.570s
user    0m17.173s
sys     0m0.395s

Environment info:

There is similar issue #2190 but looks like it's caused by different pattern of code.

anmonteiro commented 1 month ago

doesn't stack overflow anymore, but might be because I'm testing on 5.x which has unlimited stack size