File tree Expand file tree Collapse file tree 6 files changed +120
-2
lines changed Expand file tree Collapse file tree 6 files changed +120
-2
lines changed Original file line number Diff line number Diff line change 1414
1515- Fix issue where long layout break added a trailing comma in partial application ` ... ` . https://github.com/rescript-lang/rescript-compiler/pull/6949
1616- Fix incorrect format of function under unary operator. https://github.com/rescript-lang/rescript-compiler/pull/6953
17+ - Fix incorrect incorrect printing of module binding with signature. https://github.com/rescript-lang/rescript-compiler/pull/6963
1718
1819# 11.1.3
1920
Original file line number Diff line number Diff line change @@ -450,6 +450,23 @@ let includeModExpr modExpr =
450450 | Parsetree. Pmod_constraint _ -> true
451451 | _ -> false
452452
453+ let modExprParens modExpr =
454+ match modExpr with
455+ | {
456+ Parsetree. pmod_desc =
457+ Pmod_constraint
458+ ( {Parsetree. pmod_desc = Pmod_structure _},
459+ {Parsetree. pmty_desc = Pmty_signature [{psig_desc = Psig_module _}]} );
460+ } ->
461+ false
462+ | {
463+ Parsetree. pmod_desc =
464+ Pmod_constraint
465+ (_, {Parsetree. pmty_desc = Pmty_signature [{psig_desc = Psig_module _}]});
466+ } ->
467+ true
468+ | _ -> false
469+
453470let arrowReturnTypExpr typExpr =
454471 match typExpr.Parsetree. ptyp_desc with
455472 | Parsetree. Ptyp_arrow _ -> true
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ val callExpr : Parsetree.expression -> kind
3232
3333val includeModExpr : Parsetree .module_expr -> bool
3434
35+ val modExprParens : Parsetree .module_expr -> bool
36+
3537val arrowReturnTypExpr : Parsetree .core_type -> bool
3638
3739val patternRecordRowRhs : Parsetree .pattern -> bool
Original file line number Diff line number Diff line change @@ -719,6 +719,11 @@ and printModuleBinding ~state ~isRec moduleBinding cmtTbl i =
719719 Doc. concat [Doc. text " : " ; printModType ~state modType cmtTbl] )
720720 | modExpr -> (printModExpr ~state modExpr cmtTbl, Doc. nil)
721721 in
722+ let modExprDocParens =
723+ if Parens. modExprParens moduleBinding.pmb_expr then
724+ Doc. concat [Doc. lparen; modExprDoc; Doc. rparen]
725+ else modExprDoc
726+ in
722727 let modName =
723728 let doc = Doc. text moduleBinding.pmb_name.Location. txt in
724729 printComments doc cmtTbl moduleBinding.pmb_name.loc
@@ -732,7 +737,7 @@ and printModuleBinding ~state ~isRec moduleBinding cmtTbl i =
732737 modName;
733738 modConstraintDoc;
734739 Doc. text " = " ;
735- modExprDoc ;
740+ modExprDocParens ;
736741 ]
737742 in
738743 printComments doc cmtTbl moduleBinding.pmb_loc
Original file line number Diff line number Diff line change @@ -22,3 +22,49 @@ let g = {
2222 module M: T = {}
2323 0
2424}
25+
26+ module M7: {
27+ module N': {
28+ let x: int
29+ }
30+ } = (M6: {
31+ module N: {
32+ let x: int
33+ }
34+ module N' = N
35+ })
36+
37+ module M8 = M7
38+
39+ module M5 = G0()
40+
41+ module M7: {
42+ let x: int
43+ } = {
44+ let x = 8
45+ }
46+
47+ module M3: {
48+ module N': {
49+ let x: int
50+ }
51+ } = {
52+ include M'
53+ }
54+
55+ module G0: (X: {}) =>
56+ {
57+ module N': {
58+ let x: int
59+ }
60+ } = F0
61+
62+ module M6 = {
63+ module D = {
64+ let y = 3
65+ }
66+ module N = {
67+ let x = 1
68+ }
69+ module N' = N
70+ }
Original file line number Diff line number Diff line change @@ -21,4 +21,51 @@ module type T = {}
2121let g = {
2222 module M : T = {}
2323 0
24- }
24+ }
25+
26+ module M7 : {
27+ module N ': {
28+ let x : int
29+ }
30+ } = (M6 : {
31+ module N : {
32+ let x : int
33+ }
34+ module N ' = N
35+ })
36+
37+
38+ module M8 = M7
39+
40+ module M5 = G0 ()
41+
42+ module M7 : {
43+ let x : int
44+ } = {
45+ let x = 8
46+ }
47+
48+ module M3 : {
49+ module N ': {
50+ let x : int
51+ }
52+ } = {
53+ include M '
54+ }
55+
56+ module G0 : (X : {}) =>
57+ {
58+ module N ': {
59+ let x : int
60+ }
61+ } = F0
62+
63+ module M6 = {
64+ module D = {
65+ let y = 3
66+ }
67+ module N = {
68+ let x = 1
69+ }
70+ module N ' = N
71+ }
You can’t perform that action at this time.
0 commit comments