Skip to content

Commit 77334f7

Browse files
committed
Fix printing of local module with type.
Fixes #6212
1 parent da35700 commit 77334f7

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
- Remove unnecessary require and import statements when using dynamic imports. https://github.com/rescript-lang/rescript-compiler/pull/6232
2222
- Fix option unboxing logic in the presence of untagged variants. https://github.com/rescript-lang/rescript-compiler/pull/6233
23+
- Fix printing of local module with type. https://github.com/rescript-lang/rescript-compiler/issues/6212
2324

2425
#### :nail_care: Polish
2526

jscomp/syntax/src/res_printer.ml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4965,6 +4965,15 @@ and printExpressionBlock ~state ~braces expr cmtTbl =
49654965
let doc = Doc.text modName.txt in
49664966
printComments doc cmtTbl modName.loc
49674967
in
4968+
let name, modExpr =
4969+
match modExpr.pmod_desc with
4970+
| Pmod_constraint (modExpr, modType) ->
4971+
let name =
4972+
Doc.concat [name; Doc.text ": "; printModType ~state modType cmtTbl]
4973+
in
4974+
(name, modExpr)
4975+
| _ -> (name, modExpr)
4976+
in
49684977
let letModuleDoc =
49694978
Doc.concat
49704979
[

jscomp/syntax/tests/printer/modExpr/expected/structure.res.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ module Empty = {/* test */}
1515
module EmptyModule = {
1616
/* TODO: management on vacation */
1717
}
18+
19+
module type T = {}
20+
21+
let g = {
22+
module M: T = {}
23+
0
24+
}

jscomp/syntax/tests/printer/modExpr/structure.res

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ module Empty = {/* test */}
1515
module EmptyModule = {
1616
/* TODO: management on vacation */
1717
}
18+
19+
module type T = {}
20+
21+
let g = {
22+
module M: T = {}
23+
0
24+
}

0 commit comments

Comments
 (0)