Semantic Diff

#9055 Parse a doc comment before a function parameter

1 commit

c0fd17fafc7e1b97683ec7dcdc8050d6edab0803..pr-9055

93540e172 · cknitt + Claude · Oct 26, 2026, 13:29 UTC

Parse a doc comment before a function parameter

Why

The formatter prints @res.doc on a parameter as a doc comment, which the parser rejected, so formatting broke a file that compiled.

modifiedAST doc comment on a parameter

let f = (/**The runner*/ run: string) => run
diagnostic
Before
I'm not sure what to parse here when looking at "DocComment The runner".
parse
After
pattern├─ attribute "res.doc"│     └─ structure_item│        ├─ Pstr_eval│        └─ expression│           └─ Pexp_constant PConst_string (source="The runner", semantic="The runner")├─ Ppat_constraint├─ pattern│  └─ Ppat_var "run"└─ core_type   └─ Ptyp_constr "string"

modifiedFormat doc comment on a parameter

let f = (@res.doc("The runner") run: string) => run
rescript
After
let f = (  /**The runner*/  run: string,) => run

Fixes #8994