reasonml / reasonml/reason

Function parameters don't always wrap when using labeled and optional parameters

Open
#2,002 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The following doesn't wrap with refmt even though the second line is > 80 characters.

let function_with_a_long_name =
    (~many=?, parameters, contained_in, this, definition, arguably, too_many) => {
  ();
  ();
};

This does wrap (similar line length, no labels):

let function_with_a_long_name =
    (
      many,
      parameters,
      contained_in,
      this,
      definition,
      arguably,
      too_many,
      wow,
    ) => {
  ();
  ();
};

This wraps too (more labels):

let function_with_a_long_name =
    (
      ~many=?,
      ~parameters,
      ~contained_in,
      this,
      definition,
      arguably,
      too_many,
    ) => {
  ();
  ();
};

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

Run refmt on the three Reason examples in the issue and compare the parameter-wrapping behavior. Locate the formatter logic for labeled and optional function parameters, then add coverage showing that the first example wraps as expected while preserving the existing cases.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.