File tree 6 files changed +120
-2
lines changed
6 files changed +120
-2
lines changed Original file line number Diff line number Diff line change 14
14
15
15
- Fix issue where long layout break added a trailing comma in partial application ` ... ` . https://github.com/rescript-lang/rescript-compiler/pull/6949
16
16
- 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
17
18
18
19
# 11.1.3
19
20
Original file line number Diff line number Diff line change @@ -450,6 +450,23 @@ let includeModExpr modExpr =
450
450
| Parsetree. Pmod_constraint _ -> true
451
451
| _ -> false
452
452
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
+
453
470
let arrowReturnTypExpr typExpr =
454
471
match typExpr.Parsetree. ptyp_desc with
455
472
| Parsetree. Ptyp_arrow _ -> true
Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ val callExpr : Parsetree.expression -> kind
32
32
33
33
val includeModExpr : Parsetree .module_expr -> bool
34
34
35
+ val modExprParens : Parsetree .module_expr -> bool
36
+
35
37
val arrowReturnTypExpr : Parsetree .core_type -> bool
36
38
37
39
val 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 =
719
719
Doc. concat [Doc. text " : " ; printModType ~state modType cmtTbl] )
720
720
| modExpr -> (printModExpr ~state modExpr cmtTbl, Doc. nil)
721
721
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
722
727
let modName =
723
728
let doc = Doc. text moduleBinding.pmb_name.Location. txt in
724
729
printComments doc cmtTbl moduleBinding.pmb_name.loc
@@ -732,7 +737,7 @@ and printModuleBinding ~state ~isRec moduleBinding cmtTbl i =
732
737
modName;
733
738
modConstraintDoc;
734
739
Doc. text " = " ;
735
- modExprDoc ;
740
+ modExprDocParens ;
736
741
]
737
742
in
738
743
printComments doc cmtTbl moduleBinding.pmb_loc
Original file line number Diff line number Diff line change @@ -22,3 +22,49 @@ let g = {
22
22
module M: T = {}
23
23
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
+ 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 = {}
21
21
let g = {
22
22
module M : T = {}
23
23
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