Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Formatter prints @res.doc on a function parameter as a doc comment that does not parse

Open
#8,994 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
68/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
ocaml
Domain
compilers

Research direction

Start by tracing bsc -format from the formatter path that prints @res.doc on function parameters; compare it with how @ocaml.doc and @ns.doc are preserved, and inspect the parser around parameter doc comments. The issue permits either keeping the attribute form in formatter output or accepting the comment in the parser. Done means the shown input formats to output that parses successfully when formatted again.

Written by the indexing model from the issue text.

Description

The formatter prints a @res.doc attribute on a function parameter as a doc comment in front of the parameter, and the parser rejects that output.

let f = (@res.doc("The runner") run: string) => run

bsc -format prints:

let f = (
  /**The runner*/
  run: string,
) => run

Formatting that output again fails:

  Syntax error!
  2 │   /**The runner*/
  3 │   run: string,

  I'm not sure what to parse here when looking at "DocComment The runner".

So formatting turns a file that compiles into one that doesn't. @ocaml.doc/@ns.doc on a parameter have been formatted unchanged, because the printer prints only res.doc as a doc comment. If #8992 lands, @res.doc is the only doc attribute left, so writing it by hand on a parameter hits this. genType's tests/gentype_tests/typescript-react-example/src/Comments.res keeps @ocaml.doc on two parameters for this reason.

Either the printer keeps the attribute form for parameters, or the parser accepts a doc comment before a parameter.

Found while working on #8978.

🤖 Generated with Claude Code

Dominant language
OCaml
Stars
7.5k
Forks
483
Avg merge
19h 35m
Merged PRs (30d)
208

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

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.

More from rescript-lang/rescript

All issues in rescript-lang/rescript

Similar issues

More Compilers issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.