reasonml / reasonml/reason

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

Open
#2,594 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Printer
Dominant language
OCaml
Stars
10.3k
Forks
438
PR merge metrics
No merged PRs in 30d

Description

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:

  • Linux buster 4.19.0-5-amd64 #1 SMP Debian 4.19.37-5 (2019-06-19) x86_64 GNU/Linux
  • Reason 3.6.0 @ 59339f6
  • OCaml 4.08.1

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the provided refmt --print=binary command against the distilled Reason snippet and inspect the refmt implementation paths it exercises. Compare this report with issue #2190, then verify that the reproduction completes without a stack overflow and retains correct formatting behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.