reasonml / reasonml/reason

Location of () and simple expressions not retained correctly when printing.

Open
#1,795 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

echo 'if (Sys.file_exists(raw_path)) {
 /* The directory exists, stop recursing but check error cases */
 if (Sys.is_directory(raw_path)) {
   /* All good */
   "asdf";
 } else {
  ()
  }
};

Shows:

if (Sys.file_exists(raw_path)) {
  /* The directory exists, stop recursing but check error cases */
  if (Sys.is_directory(raw_path)) {
    "asdf";
    /* All good */
  } else {
    ();
  };
};

You can replace the string "asdf" with () or 45 and it still has the same issue.
I think the location of constants isn't getting correctly recorded.

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

No source file, test, or entry point is named. Reproduce the supplied formatter example and trace how locations for nested simple expressions are recorded and used during printing; done means the output preserves the original placement of (), constants, and comments in this example and its variants.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
compilers
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.