Skip to content

Commit fb73597

Browse files
Fix printing of Osig_module in outcome printer. (rescript-lang#404)
Modules types don't use a `=`, it should be a `:`. ``` module Expr: { … } ```
1 parent 1ed8132 commit fb73597

File tree

3 files changed

+72
-9
lines changed

3 files changed

+72
-9
lines changed

syntax/src/res_outcome_printer.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -666,10 +666,10 @@ let printPolyVarIdent txt =
666666
match outRecStatus with
667667
| Orec_not -> "module "
668668
| Orec_first -> "module rec "
669-
| Orec_next -> "and"
669+
| Orec_next -> "and "
670670
);
671671
Doc.text modName;
672-
Doc.text " = ";
672+
Doc.text ": ";
673673
printOutModuleTypeDoc outModType;
674674
]
675675
)

syntax/tests/oprint/expected/oprint.res.txt

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type user2 = {
1212
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaage: int,
1313
emaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaail: string,
1414
}
15-
module Diff = {
15+
module Diff: {
1616
let string: (string, string) => bool
1717
}
1818
module Diff2 = Diff
@@ -42,12 +42,12 @@ type color +=
4242
| Blaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaack
4343
| Oraaaaaaaaaaaaaaaaaaaaaaaaaaaaaaange
4444
| Reeeeeeeeeeeeeeeeeeeed
45-
module Expr = {
45+
module Expr: {
4646
type attr = ..
4747
type attr += private Str(string)
4848
type attr += Int(int) | Float(float)
4949
}
50-
module User = {
50+
module User: {
5151
type t = {name: string, age: int}
5252
}
5353
type userT = User.t = {name: string, age: int}
@@ -77,7 +77,7 @@ type redColor = [#Red]
7777
type greenColor = [#Green]
7878
type blueColor = [#Blue]
7979
type rgbColor = [#Blue | #Green | #Red]
80-
module M = {
80+
module M: {
8181
type data = [#IntData(int) | #StrData(string)]
8282
let stringOfData: data => string
8383
}
@@ -149,9 +149,9 @@ type \"let" = int
149149
type \"type" = [#"Point🗿"(\"let", float)]
150150
type t23 = [#1 | #"10space" | #123]
151151
type exoticUser = {\"let": string, \"type": float}
152-
module Js = {
152+
module Js: {
153153
type t<'a> = 'a
154-
module Fn = {
154+
module Fn: {
155155
type arity0<'a> = {i0: unit => 'a}
156156
type arity1<'a> = {i1: 'a}
157157
type arity2<'a> = {i2: 'a}
@@ -447,4 +447,47 @@ type picture = string
447447
module type DEVICE = {
448448
let draw: picture => unit
449449
}
450-
let devices: Hashtbl.t<string, module(DEVICE)>
450+
let devices: Hashtbl.t<string, module(DEVICE)>
451+
module rec A: {
452+
type t = Leaf(string) | Node(ASet.t)
453+
let compare: (t, t) => int
454+
}
455+
and ASet: {
456+
type rec elt = A.t
457+
type rec t
458+
let empty: t
459+
let is_empty: t => bool
460+
let mem: (elt, t) => bool
461+
let add: (elt, t) => t
462+
let singleton: elt => t
463+
let remove: (elt, t) => t
464+
let union: (t, t) => t
465+
let inter: (t, t) => t
466+
let diff: (t, t) => t
467+
let compare: (t, t) => int
468+
let equal: (t, t) => bool
469+
let subset: (t, t) => bool
470+
let iter: (elt => unit, t) => unit
471+
let map: (elt => elt, t) => t
472+
let fold: ((elt, 'a) => 'a, t, 'a) => 'a
473+
let for_all: (elt => bool, t) => bool
474+
let exists: (elt => bool, t) => bool
475+
let filter: (elt => bool, t) => t
476+
let partition: (elt => bool, t) => (t, t)
477+
let cardinal: t => int
478+
let elements: t => list<elt>
479+
let min_elt: t => elt
480+
let min_elt_opt: t => option<elt>
481+
let max_elt: t => elt
482+
let max_elt_opt: t => option<elt>
483+
let choose: t => elt
484+
let choose_opt: t => option<elt>
485+
let split: (elt, t) => (t, bool, t)
486+
let find: (elt, t) => elt
487+
let find_opt: (elt, t) => option<elt>
488+
let find_first: (elt => bool, t) => elt
489+
let find_first_opt: (elt => bool, t) => option<elt>
490+
let find_last: (elt => bool, t) => elt
491+
let find_last_opt: (elt => bool, t) => option<elt>
492+
let of_list: list<elt> => t
493+
}

syntax/tests/oprint/oprint.res

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,3 +313,23 @@ module type DEVICE = {
313313
}
314314

315315
let devices: Hashtbl.t<string, module(DEVICE)> = Hashtbl.create(17)
316+
317+
module rec A: {
318+
type t =
319+
| Leaf(string)
320+
| Node(ASet.t)
321+
let compare: (t, t) => int
322+
} = {
323+
type t =
324+
| Leaf(string)
325+
| Node(ASet.t)
326+
let compare = (t1, t2) =>
327+
switch (t1, t2) {
328+
| (Leaf(s1), Leaf(s2)) => compare(s1, s2)
329+
| (Leaf(_), Node(_)) => 1
330+
| (Node(_), Leaf(_)) => -1
331+
| (Node(n1), Node(n2)) => ASet.compare(n1, n2)
332+
}
333+
}
334+
and ASet: Set.S with type elt = A.t = Set.Make(A)
335+

0 commit comments

Comments
 (0)