Skip to content

Commit 119d36c

Browse files
committed
convert more warnings in OCaml syntax to ReScript syntax
1 parent 3c5f1a2 commit 119d36c

File tree

6 files changed

+135
-40
lines changed

6 files changed

+135
-40
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
2+
Warning number 9
3+
/.../fixtures/warnings5.res:12:3-21
4+
5+
10 │
6+
11 │ switch y {
7+
12 │ | {otherValue: false} => Js.log("first")
8+
13 │ }
9+
14 │
10+
11+
the following labels are not bound in this record pattern: someValue, typ
12+
Either bind these labels explicitly or add '; _' to the pattern.
13+
14+
15+
Warning number 8
16+
/.../fixtures/warnings5.res:11:1-13:1
17+
18+
9 │ @val external y: someRecord = "otherVariable"
19+
10 │
20+
11 │ switch y {
21+
12 │ | {otherValue: false} => Js.log("first")
22+
13 │ }
23+
14 │
24+
15 │ switch y {
25+
26+
You forgot to handle a possible case here, for example:
27+
{otherValue: true}
28+
29+
30+
Warning number 9
31+
/.../fixtures/warnings5.res:16:3-26
32+
33+
14 │
34+
15 │ switch y {
35+
16 │ | {typ: WithPayload(true)} => Js.log("first")
36+
17 │ }
37+
18 │
38+
39+
the following labels are not bound in this record pattern: someValue, otherValue
40+
Either bind these labels explicitly or add '; _' to the pattern.
41+
42+
43+
Warning number 8
44+
/.../fixtures/warnings5.res:15:1-17:1
45+
46+
13 │ }
47+
14 │
48+
15 │ switch y {
49+
16 │ | {typ: WithPayload(true)} => Js.log("first")
50+
17 │ }
51+
18 │
52+
19 │ let arr = [1]
53+
54+
You forgot to handle a possible case here, for example:
55+
({typ: WithPayload(false)}|{typ: Variant})
56+
57+
58+
Warning number 8
59+
/.../fixtures/warnings5.res:21:1-23:1
60+
61+
19 │ let arr = [1]
62+
20 │
63+
21 │ switch arr {
64+
22 │ | [] => Js.log("")
65+
23 │ }
66+
24 │
67+
25 │ switch arr {
68+
69+
You forgot to handle a possible case here, for example:
70+
[_]
71+
72+
73+
Warning number 8
74+
/.../fixtures/warnings5.res:25:1-27:1
75+
76+
23 │ }
77+
24 │
78+
25 │ switch arr {
79+
26 │ | [one] => Js.log(one)
80+
27 │ }
81+
28 │
82+
83+
You forgot to handle a possible case here, for example:
84+
[]
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
type someTyp = Variant | WithPayload(bool)
2+
3+
type someRecord = {
4+
someValue: string,
5+
otherValue: bool,
6+
typ: someTyp,
7+
}
8+
9+
@val external y: someRecord = "otherVariable"
10+
11+
switch y {
12+
| {otherValue: false} => Js.log("first")
13+
}
14+
15+
switch y {
16+
| {typ: WithPayload(true)} => Js.log("first")
17+
}
18+
19+
let arr = [1]
20+
21+
switch arr {
22+
| [] => Js.log("")
23+
}
24+
25+
switch arr {
26+
| [one] => Js.log(one)
27+
}

jscomp/ml/parmatch.ml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ let rec pretty_val ppf v =
406406
| Tpat_construct (_, cstr, []) ->
407407
fprintf ppf "%s" cstr.cstr_name
408408
| Tpat_construct (_, cstr, [w]) ->
409-
fprintf ppf "@[<2>%s@ %a@]" cstr.cstr_name pretty_arg w
409+
fprintf ppf "@[<2>%s(%a)@]" cstr.cstr_name pretty_arg w
410410
| Tpat_construct (_, cstr, vs) ->
411411
let name = cstr.cstr_name in
412412
begin match (name, vs) with
@@ -426,17 +426,13 @@ let rec pretty_val ppf v =
426426
| _ -> true) in
427427
begin match filtered_lvs with
428428
| [] -> fprintf ppf "_"
429-
| (_, lbl, _) :: q ->
430-
let elision_mark ppf =
431-
(* we assume that there is no label repetitions here *)
432-
if Array.length lbl.lbl_all > 1 + List.length q then
433-
fprintf ppf ";@ _@ "
434-
else () in
429+
| (_, _lbl, _) :: _q ->
430+
let elision_mark _ = () in
435431
fprintf ppf "@[{%a%t}@]"
436432
pretty_lvals filtered_lvs elision_mark
437433
end
438434
| Tpat_array vs ->
439-
fprintf ppf "@[[| %a |]@]" (pretty_vals " ;") vs
435+
fprintf ppf "@[[%a]@]" (pretty_vals " ;") vs
440436
| Tpat_lazy v ->
441437
fprintf ppf "@[<2>lazy@ %a@]" pretty_arg v
442438
| Tpat_alias (v, x,_) ->
@@ -475,9 +471,9 @@ and pretty_vals sep ppf = function
475471
and pretty_lvals ppf = function
476472
| [] -> ()
477473
| [_,lbl,v] ->
478-
fprintf ppf "%s=%a" lbl.lbl_name pretty_val v
474+
fprintf ppf "%s: %a" lbl.lbl_name pretty_val v
479475
| (_, lbl,v)::rest ->
480-
fprintf ppf "%s=%a;@ %a"
476+
fprintf ppf "%s: %a,@ %a"
481477
lbl.lbl_name pretty_val v pretty_lvals rest
482478

483479
let top_pretty ppf v =

lib/4.06.1/unstable/js_compiler.ml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26812,7 +26812,7 @@ let rec pretty_val ppf v =
2681226812
| Tpat_construct (_, cstr, []) ->
2681326813
fprintf ppf "%s" cstr.cstr_name
2681426814
| Tpat_construct (_, cstr, [w]) ->
26815-
fprintf ppf "@[<2>%s@ %a@]" cstr.cstr_name pretty_arg w
26815+
fprintf ppf "@[<2>%s(%a)@]" cstr.cstr_name pretty_arg w
2681626816
| Tpat_construct (_, cstr, vs) ->
2681726817
let name = cstr.cstr_name in
2681826818
begin match (name, vs) with
@@ -26832,17 +26832,13 @@ let rec pretty_val ppf v =
2683226832
| _ -> true) in
2683326833
begin match filtered_lvs with
2683426834
| [] -> fprintf ppf "_"
26835-
| (_, lbl, _) :: q ->
26836-
let elision_mark ppf =
26837-
(* we assume that there is no label repetitions here *)
26838-
if Array.length lbl.lbl_all > 1 + List.length q then
26839-
fprintf ppf ";@ _@ "
26840-
else () in
26835+
| (_, _lbl, _) :: _q ->
26836+
let elision_mark _ = () in
2684126837
fprintf ppf "@[{%a%t}@]"
2684226838
pretty_lvals filtered_lvs elision_mark
2684326839
end
2684426840
| Tpat_array vs ->
26845-
fprintf ppf "@[[| %a |]@]" (pretty_vals " ;") vs
26841+
fprintf ppf "@[[%a]@]" (pretty_vals " ;") vs
2684626842
| Tpat_lazy v ->
2684726843
fprintf ppf "@[<2>lazy@ %a@]" pretty_arg v
2684826844
| Tpat_alias (v, x,_) ->
@@ -26881,9 +26877,9 @@ and pretty_vals sep ppf = function
2688126877
and pretty_lvals ppf = function
2688226878
| [] -> ()
2688326879
| [_,lbl,v] ->
26884-
fprintf ppf "%s=%a" lbl.lbl_name pretty_val v
26880+
fprintf ppf "%s: %a" lbl.lbl_name pretty_val v
2688526881
| (_, lbl,v)::rest ->
26886-
fprintf ppf "%s=%a;@ %a"
26882+
fprintf ppf "%s: %a,@ %a"
2688726883
lbl.lbl_name pretty_val v pretty_lvals rest
2688826884

2688926885
let top_pretty ppf v =

lib/4.06.1/unstable/js_playground_compiler.ml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26812,7 +26812,7 @@ let rec pretty_val ppf v =
2681226812
| Tpat_construct (_, cstr, []) ->
2681326813
fprintf ppf "%s" cstr.cstr_name
2681426814
| Tpat_construct (_, cstr, [w]) ->
26815-
fprintf ppf "@[<2>%s@ %a@]" cstr.cstr_name pretty_arg w
26815+
fprintf ppf "@[<2>%s(%a)@]" cstr.cstr_name pretty_arg w
2681626816
| Tpat_construct (_, cstr, vs) ->
2681726817
let name = cstr.cstr_name in
2681826818
begin match (name, vs) with
@@ -26832,17 +26832,13 @@ let rec pretty_val ppf v =
2683226832
| _ -> true) in
2683326833
begin match filtered_lvs with
2683426834
| [] -> fprintf ppf "_"
26835-
| (_, lbl, _) :: q ->
26836-
let elision_mark ppf =
26837-
(* we assume that there is no label repetitions here *)
26838-
if Array.length lbl.lbl_all > 1 + List.length q then
26839-
fprintf ppf ";@ _@ "
26840-
else () in
26835+
| (_, _lbl, _) :: _q ->
26836+
let elision_mark _ = () in
2684126837
fprintf ppf "@[{%a%t}@]"
2684226838
pretty_lvals filtered_lvs elision_mark
2684326839
end
2684426840
| Tpat_array vs ->
26845-
fprintf ppf "@[[| %a |]@]" (pretty_vals " ;") vs
26841+
fprintf ppf "@[[%a]@]" (pretty_vals " ;") vs
2684626842
| Tpat_lazy v ->
2684726843
fprintf ppf "@[<2>lazy@ %a@]" pretty_arg v
2684826844
| Tpat_alias (v, x,_) ->
@@ -26881,9 +26877,9 @@ and pretty_vals sep ppf = function
2688126877
and pretty_lvals ppf = function
2688226878
| [] -> ()
2688326879
| [_,lbl,v] ->
26884-
fprintf ppf "%s=%a" lbl.lbl_name pretty_val v
26880+
fprintf ppf "%s: %a" lbl.lbl_name pretty_val v
2688526881
| (_, lbl,v)::rest ->
26886-
fprintf ppf "%s=%a;@ %a"
26882+
fprintf ppf "%s: %a,@ %a"
2688726883
lbl.lbl_name pretty_val v pretty_lvals rest
2688826884

2688926885
let top_pretty ppf v =

lib/4.06.1/whole_compiler.ml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186753,7 +186753,7 @@ let rec pretty_val ppf v =
186753186753
| Tpat_construct (_, cstr, []) ->
186754186754
fprintf ppf "%s" cstr.cstr_name
186755186755
| Tpat_construct (_, cstr, [w]) ->
186756-
fprintf ppf "@[<2>%s@ %a@]" cstr.cstr_name pretty_arg w
186756+
fprintf ppf "@[<2>%s(%a)@]" cstr.cstr_name pretty_arg w
186757186757
| Tpat_construct (_, cstr, vs) ->
186758186758
let name = cstr.cstr_name in
186759186759
begin match (name, vs) with
@@ -186773,17 +186773,13 @@ let rec pretty_val ppf v =
186773186773
| _ -> true) in
186774186774
begin match filtered_lvs with
186775186775
| [] -> fprintf ppf "_"
186776-
| (_, lbl, _) :: q ->
186777-
let elision_mark ppf =
186778-
(* we assume that there is no label repetitions here *)
186779-
if Array.length lbl.lbl_all > 1 + List.length q then
186780-
fprintf ppf ";@ _@ "
186781-
else () in
186776+
| (_, _lbl, _) :: _q ->
186777+
let elision_mark _ = () in
186782186778
fprintf ppf "@[{%a%t}@]"
186783186779
pretty_lvals filtered_lvs elision_mark
186784186780
end
186785186781
| Tpat_array vs ->
186786-
fprintf ppf "@[[| %a |]@]" (pretty_vals " ;") vs
186782+
fprintf ppf "@[[%a]@]" (pretty_vals " ;") vs
186787186783
| Tpat_lazy v ->
186788186784
fprintf ppf "@[<2>lazy@ %a@]" pretty_arg v
186789186785
| Tpat_alias (v, x,_) ->
@@ -186822,9 +186818,9 @@ and pretty_vals sep ppf = function
186822186818
and pretty_lvals ppf = function
186823186819
| [] -> ()
186824186820
| [_,lbl,v] ->
186825-
fprintf ppf "%s=%a" lbl.lbl_name pretty_val v
186821+
fprintf ppf "%s: %a" lbl.lbl_name pretty_val v
186826186822
| (_, lbl,v)::rest ->
186827-
fprintf ppf "%s=%a;@ %a"
186823+
fprintf ppf "%s: %a,@ %a"
186828186824
lbl.lbl_name pretty_val v pretty_lvals rest
186829186825

186830186826
let top_pretty ppf v =

0 commit comments

Comments
 (0)