Skip to content

Commit 3f22f9a

Browse files
authored
Handle doc comment in recursive module (#6613)
* Handle doc comment * Expand DocComments test * Update changelog
1 parent 0d0d7a0 commit 3f22f9a

File tree

4 files changed

+45
-1
lines changed

4 files changed

+45
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Generic JSX transform: Rename expected module name for lowercase JSX to `Elements` from `DOM`. https://github.com/rescript-lang/rescript-compiler/pull/6606
1919
- Generic JSX transform: Set default config params for `jsxConfig`. https://github.com/rescript-lang/rescript-compiler/pull/6606
2020
- Generic JSX transform: Handle namespaced names. https://github.com/rescript-lang/rescript-compiler/pull/6606
21+
- Fix issue with doc comment in recursive module. https://github.com/rescript-lang/rescript-compiler/pull/6613
2122

2223
#### :house: Internal
2324

jscomp/syntax/src/res_core.ml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6028,7 +6028,14 @@ and parseModuleBindingBody p =
60286028
and parseModuleBindings ~attrs ~startPos p =
60296029
let rec loop p acc =
60306030
let startPos = p.Parser.startPos in
6031-
let attrs = parseAttributesAndBinding p in
6031+
let docAttr : Parsetree.attributes =
6032+
match p.Parser.token with
6033+
| DocComment (loc, s) ->
6034+
Parser.next p;
6035+
[docCommentToAttribute loc s]
6036+
| _ -> []
6037+
in
6038+
let attrs = docAttr @ parseAttributesAndBinding p in
60326039
match p.Parser.token with
60336040
| And ->
60346041
Parser.next p;

jscomp/syntax/tests/printer/expr/DocComments.res

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,18 @@ module M : {
1111

1212
@val
1313
external ex : (/** ddd */ ~x: int, /** eee */ n) => int = "ex"
14+
15+
/** A */
16+
module rec A : { type t } = {
17+
type t
18+
}
19+
20+
/** B */
21+
and B : { type t } = {
22+
type t
23+
}
24+
25+
@res.doc(" C ")
26+
and C : { type t} = {
27+
type t
28+
}

jscomp/syntax/tests/printer/expr/expected/DocComments.res.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,24 @@ module M: {
1111

1212
@val
1313
external ex: (/** ddd */ ~x: int, /** eee */ n) => int = "ex"
14+
15+
/** A */
16+
module rec A: {
17+
type t
18+
} = {
19+
type t
20+
}
21+
22+
/** B */
23+
and B: {
24+
type t
25+
} = {
26+
type t
27+
}
28+
29+
/** C */
30+
and C: {
31+
type t
32+
} = {
33+
type t
34+
}

0 commit comments

Comments
 (0)