From a39bd9a6409028b088e2b2076dec1570427a0366 Mon Sep 17 00:00:00 2001 From: raptazure Date: Mon, 23 Nov 2020 08:24:13 +0800 Subject: [PATCH 1/3] recursion: fix multiple definition of the type --- docs/recursion.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/recursion.md b/docs/recursion.md index 0c90de516c..802581bbcf 100644 --- a/docs/recursion.md +++ b/docs/recursion.md @@ -76,10 +76,10 @@ Opt-out of recursive types using the `nonrec` keyword: ```reason type t = string; -type nonrec t = list(t); +type nonrec t' = list(t); -/* t is now list(string) */ -let x: t = ["hello", "world"]; +/* t' is now list(string) */ +let x: t' = ["hello", "world"]; ``` ## Mutually Recursive Types From 5170a8e21c46c05503678832c3f79eae0402e610 Mon Sep 17 00:00:00 2001 From: raptazure Date: Mon, 23 Nov 2020 08:46:43 +0800 Subject: [PATCH 2/3] pattern: fix unbound type constructor r --- docs/pattern-matching.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/pattern-matching.md b/docs/pattern-matching.md index 4d997d4423..2d5c7c4e71 100644 --- a/docs/pattern-matching.md +++ b/docs/pattern-matching.md @@ -132,15 +132,15 @@ type point = { type t = | A((string, int)) - | B(r) + | B(point) | C(array(int)) - | D(list(r)); + | D(list(point)); -let x = D([{x: 2, y: 1.2}]); +let x = D([{x: 2, y: 1}]); switch (x) { | A(("hi", num)) => num -| B({x, y: 1.2}) => x +| B({x, y: 1}) => x | C([|x|]) => x | C([|2, 3, x|]) => x | D([]) => 2 @@ -156,8 +156,8 @@ switch (x) { ```reason switch (x) { | A(("hi", num)) as v => f(v) -| B({x: _, y: 1.2} as r) => g(r) -| D([{x: _, y: 1.2} as r, ..._]) => g(r) +| B({x: _, y: 1} as r) => g(r) +| D([{x: _, y: 1} as r, ..._]) => g(r) | _ => 42 }; ``` From b34569fece17bbc155bcf261d8b0c47b4fc50c21 Mon Sep 17 00:00:00 2001 From: raptazure Date: Wed, 2 Dec 2020 12:26:49 +0800 Subject: [PATCH 3/3] fix nonrec example that gives a compilation error --- docs/recursion.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/recursion.md b/docs/recursion.md index 802581bbcf..e79684d901 100644 --- a/docs/recursion.md +++ b/docs/recursion.md @@ -76,10 +76,12 @@ Opt-out of recursive types using the `nonrec` keyword: ```reason type t = string; -type nonrec t' = list(t); +module M = { + type nonrec t = list(t); +}; -/* t' is now list(string) */ -let x: t' = ["hello", "world"]; +/* t is now list(string) */ +let x: M.t = ["Hello", "World"] ``` ## Mutually Recursive Types