Skip to content

Commit 564c7c4

Browse files
authored
Merge pull request #5061 from rescript-lang/upgrade_syntax
upgrade syntax repo
2 parents 37f9c07 + 3cc5d11 commit 564c7c4

File tree

7 files changed

+230
-148
lines changed

7 files changed

+230
-148
lines changed

jscomp/test/hello_res.res

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
11
@@config({
2-
flags : [
3-
"-dparsetree"
4-
]
2+
flags: ["-dparsetree"],
53
})
64

7-
let b = List.length(list{1,2,3})
5+
let b = List.length(list{1, 2, 3})
86
let a = b - 1
9-
Js.log ("hello, res")
7+
Js.log("hello, res")
108

11-
type t = { "x" : int }
9+
type t = {"x": int}
1210

11+
type h = {...t, "y": string}
1312

14-
type h = {... t , "y" : string}
15-
16-
let u01 : h = {"x" : 3 , "y" : "x"}
17-
let u : t = {"x" : 3 }
13+
let u01: h = {"x": 3, "y": "x"}
14+
let u: t = {"x": 3}
1815

1916
let h = u["x"]
2017

21-
%%private(
22-
let {length, cons } = module (List)
23-
)
24-
25-
18+
%%private(let {length, cons} = module(List))
2619

2720
%%private(let {length, cons} = module(List))
2821

@@ -48,4 +41,4 @@ let h = {
4841
let to = 3
4942
let downto = 1
5043

51-
Js.log([to,downto])
44+
Js.log([to, downto])

jscomp/test/inline_map_demo.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function bal(l, x, d, r) {
4343
RE_EXN_ID: "Assert_failure",
4444
_1: [
4545
"inline_map_demo.res",
46-
48,
46+
47,
4747
19
4848
],
4949
Error: new Error()
@@ -53,7 +53,7 @@ function bal(l, x, d, r) {
5353
RE_EXN_ID: "Assert_failure",
5454
_1: [
5555
"inline_map_demo.res",
56-
42,
56+
41,
5757
15
5858
],
5959
Error: new Error()
@@ -83,7 +83,7 @@ function bal(l, x, d, r) {
8383
RE_EXN_ID: "Assert_failure",
8484
_1: [
8585
"inline_map_demo.res",
86-
62,
86+
61,
8787
19
8888
],
8989
Error: new Error()
@@ -93,7 +93,7 @@ function bal(l, x, d, r) {
9393
RE_EXN_ID: "Assert_failure",
9494
_1: [
9595
"inline_map_demo.res",
96-
56,
96+
55,
9797
15
9898
],
9999
Error: new Error()

jscomp/test/inline_map_demo.res

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
let compare = (x: int, y: int) => compare(x, y)
44

5-
65
type rec t<'a> =
76
| Empty
87
| Node(t<'a>, int, 'a, t<'a>, int)

jscomp/test/int_poly_var.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,9 @@ var tuple = [
134134
hh10
135135
];
136136

137-
Mt.eq_suites(id, suites, "File \"int_poly_var.res\", line 83, characters 20-27", hihi, 3);
137+
Mt.eq_suites(id, suites, "File \"int_poly_var.res\", line 79, characters 22-29", hihi, 3);
138138

139-
Mt.eq_suites(id, suites, "File \"int_poly_var.res\", line 84, characters 20-27", tuple, [
139+
Mt.eq_suites(id, suites, "File \"int_poly_var.res\", line 80, characters 22-29", tuple, [
140140
0,
141141
1,
142142
2,
@@ -159,7 +159,11 @@ function hh1(x) {
159159
}
160160

161161
function f(x) {
162-
return x;
162+
if (x.NAME === 1) {
163+
return x.VAL;
164+
} else {
165+
return String(x.VAL);
166+
}
163167
}
164168

165169
Mt.from_pair_suites("int_poly_var.res", suites.contents);

jscomp/test/int_poly_var.res

Lines changed: 74 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,100 +1,101 @@
1-
2-
let {eq_suites} = module (Mt)
1+
let {eq_suites} = module(Mt)
32
let id = ref(0)
43
let suites = ref(list{})
5-
let u = #"1"
6-
4+
let u = #1
75

86
type t = [
9-
| #"0"
10-
| #"1"
11-
| #"2"
7+
| #0
8+
| #1
9+
| #2
1210
]
13-
type h =
14-
| A (t)
15-
| B (t,int )
16-
17-
let nest = (x : h) => {
18-
switch(x){
19-
| A(#"0") => 0
20-
| A(#"1") => 1
21-
| A (_) => 2
22-
| B(_,0) => 3
23-
| B(#"1",_) => 4
24-
| B(#"2",_) => 5
25-
| B(#"0",_) => 6
26-
27-
}
28-
}
11+
type h =
12+
| A(t)
13+
| B(t, int)
14+
15+
let nest = (x: h) => {
16+
switch x {
17+
| A(#0) => 0
18+
| A(#1) => 1
19+
| A(_) => 2
20+
| B(_, 0) => 3
21+
| B(#1, _) => 4
22+
| B(#2, _) => 5
23+
| B(#0, _) => 6
24+
}
25+
}
2926
@inline
30-
let f = (x:t) => {
31-
switch(x){
32-
|#"0" => 'a'
33-
|#"1" => 'b'
34-
|#"2" => 'c'
35-
}
27+
let f = (x: t) => {
28+
switch x {
29+
| #0 => 'a'
30+
| #1 => 'b'
31+
| #2 => 'c'
32+
}
3633
}
3734

38-
let f2 = (x,b) => {
39-
switch(x){
40-
|#"0" => 3
41-
|#"1" => b
42-
|#"c" => 33
43-
|#"2" => 0
44-
}
35+
let f2 = (x, b) => {
36+
switch x {
37+
| #0 => 3
38+
| #1 => b
39+
| #c => 33
40+
| #2 => 0
41+
}
4542
}
4643

47-
4844
// typeof x === "string"
4945
// is no longer correct
5046
// we should use !== "object"
51-
let f3 = (x,b) => {
52-
switch(x){
53-
|#"12" (y) => y
54-
|#"23" (z) => z
55-
|#"32"(h,_) => h
56-
|#"3" => 3
57-
|#"333" (_,h) => h
58-
}
47+
let f3 = (x, b) => {
48+
switch x {
49+
| #12(y) => y
50+
| #23(z) => z
51+
| #32(h, _) => h
52+
| #3 => 3
53+
| #333(_, h) => h
54+
}
5955
}
60-
let h = (x) => x == #"0"
56+
let h = x => x == #0
6157

62-
let g = f (#"1")
58+
let g = f(#1)
6359

64-
let hihi = f3 (#"3",0)
60+
let hihi = f3(#3, 0)
6561

66-
let hh9 = 3 == Obj.magic(#"3")
67-
let hh10 = "3" == Obj.magic(#"3")
62+
let hh9 = 3 == Obj.magic(#3)
63+
let hh10 = "3" == Obj.magic(#3)
6864
let tuple = (
69-
nest(A(#"0")),
70-
nest(A(#"1")),
71-
nest(A(#"2")),
72-
nest(B(#"1",0)),
73-
nest(B(#"1",1)),
74-
nest(B(#"2",1)),
75-
nest(B(#"2",2)),
76-
nest(B(#"0",0)),
77-
nest(B(#"0",1)),
78-
hh9,
79-
hh10
65+
nest(A(#0)),
66+
nest(A(#1)),
67+
nest(A(#2)),
68+
nest(B(#1, 0)),
69+
nest(B(#1, 1)),
70+
nest(B(#2, 1)),
71+
nest(B(#2, 2)),
72+
nest(B(#0, 0)),
73+
nest(B(#0, 1)),
74+
hh9,
75+
hh10,
8076
)
8177

82-
let begin = 3
83-
eq_suites(id,suites,__LOC__,hihi,3)
84-
eq_suites(id,suites,__LOC__,tuple,(0,1,2,3,4,5,5,3,6,true,false))
78+
let begin = 3
79+
eq_suites(id, suites, __LOC__, hihi, 3)
80+
eq_suites(id, suites, __LOC__, tuple, (0, 1, 2, 3, 4, 5, 5, 3, 6, true, false))
8581

86-
let hh0 = ( x : list<t>) => ( x :> list <int>)
87-
let hh1 = ( x : list< [ #a | #b ]>) => ( x :> list <string>)
82+
let hh0 = (x: list<t>) => (x :> list<int>)
83+
let hh1 = (x: list<[#a | #b]>) => (x :> list<string>)
8884

89-
// let hh2 = ( x : [#a (int)]) => ( x :> string)
90-
// let hh2 = ( x : [#a (int)]) => ( x :> int)
85+
// let hh2 = ( x : [#a (int)]) => ( x :> string)
86+
// let hh2 = ( x : [#a (int)]) => ( x :> int)
9187
// let hh1 = ( x : list< [< #a | #b ]>) => ( x :> list <string>)
9288

89+
type t0 = [#a | #b]
9390

91+
let f = (x: list<t0>) => (x :> list<Test2.U.H.t>)
9492

95-
type t0 = [#a|#b]
93+
type u = [#0(int) | #1(string)]
9694

97-
let f = (x : list<t0>) =>
98-
(x :> list<Test2.U.H.t>)
99-
100-
Mt.from_pair_suites(__FILE__,suites.contents)
95+
let f = (x: u) => {
96+
switch x {
97+
| #0(x) => string_of_int(x)
98+
| #1(x) => x
99+
}
100+
}
101+
Mt.from_pair_suites(__FILE__, suites.contents)

0 commit comments

Comments
 (0)