Skip to content

upgrade syntax repo #5061

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions jscomp/test/hello_res.res
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
@@config({
flags : [
"-dparsetree"
]
flags: ["-dparsetree"],
})

let b = List.length(list{1,2,3})
let b = List.length(list{1, 2, 3})
let a = b - 1
Js.log ("hello, res")
Js.log("hello, res")

type t = { "x" : int }
type t = {"x": int}

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

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

let u01 : h = {"x" : 3 , "y" : "x"}
let u : t = {"x" : 3 }
let u01: h = {"x": 3, "y": "x"}
let u: t = {"x": 3}

let h = u["x"]

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


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

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

Expand All @@ -48,4 +41,4 @@ let h = {
let to = 3
let downto = 1

Js.log([to,downto])
Js.log([to, downto])
8 changes: 4 additions & 4 deletions jscomp/test/inline_map_demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function bal(l, x, d, r) {
RE_EXN_ID: "Assert_failure",
_1: [
"inline_map_demo.res",
48,
47,
19
],
Error: new Error()
Expand All @@ -53,7 +53,7 @@ function bal(l, x, d, r) {
RE_EXN_ID: "Assert_failure",
_1: [
"inline_map_demo.res",
42,
41,
15
],
Error: new Error()
Expand Down Expand Up @@ -83,7 +83,7 @@ function bal(l, x, d, r) {
RE_EXN_ID: "Assert_failure",
_1: [
"inline_map_demo.res",
62,
61,
19
],
Error: new Error()
Expand All @@ -93,7 +93,7 @@ function bal(l, x, d, r) {
RE_EXN_ID: "Assert_failure",
_1: [
"inline_map_demo.res",
56,
55,
15
],
Error: new Error()
Expand Down
1 change: 0 additions & 1 deletion jscomp/test/inline_map_demo.res
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

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


type rec t<'a> =
| Empty
| Node(t<'a>, int, 'a, t<'a>, int)
Expand Down
10 changes: 7 additions & 3 deletions jscomp/test/int_poly_var.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,9 @@ var tuple = [
hh10
];

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

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

function f(x) {
return x;
if (x.NAME === 1) {
return x.VAL;
} else {
return String(x.VAL);
}
}

Mt.from_pair_suites("int_poly_var.res", suites.contents);
Expand Down
147 changes: 74 additions & 73 deletions jscomp/test/int_poly_var.res
Original file line number Diff line number Diff line change
@@ -1,100 +1,101 @@

let {eq_suites} = module (Mt)
let {eq_suites} = module(Mt)
let id = ref(0)
let suites = ref(list{})
let u = #"1"

let u = #1

type t = [
| #"0"
| #"1"
| #"2"
| #0
| #1
| #2
]
type h =
| A (t)
| B (t,int )

let nest = (x : h) => {
switch(x){
| A(#"0") => 0
| A(#"1") => 1
| A (_) => 2
| B(_,0) => 3
| B(#"1",_) => 4
| B(#"2",_) => 5
| B(#"0",_) => 6

}
}
type h =
| A(t)
| B(t, int)

let nest = (x: h) => {
switch x {
| A(#0) => 0
| A(#1) => 1
| A(_) => 2
| B(_, 0) => 3
| B(#1, _) => 4
| B(#2, _) => 5
| B(#0, _) => 6
}
}
@inline
let f = (x:t) => {
switch(x){
|#"0" => 'a'
|#"1" => 'b'
|#"2" => 'c'
}
let f = (x: t) => {
switch x {
| #0 => 'a'
| #1 => 'b'
| #2 => 'c'
}
}

let f2 = (x,b) => {
switch(x){
|#"0" => 3
|#"1" => b
|#"c" => 33
|#"2" => 0
}
let f2 = (x, b) => {
switch x {
| #0 => 3
| #1 => b
| #c => 33
| #2 => 0
}
}


// typeof x === "string"
// is no longer correct
// we should use !== "object"
let f3 = (x,b) => {
switch(x){
|#"12" (y) => y
|#"23" (z) => z
|#"32"(h,_) => h
|#"3" => 3
|#"333" (_,h) => h
}
let f3 = (x, b) => {
switch x {
| #12(y) => y
| #23(z) => z
| #32(h, _) => h
| #3 => 3
| #333(_, h) => h
}
}
let h = (x) => x == #"0"
let h = x => x == #0

let g = f (#"1")
let g = f(#1)

let hihi = f3 (#"3",0)
let hihi = f3(#3, 0)

let hh9 = 3 == Obj.magic(#"3")
let hh10 = "3" == Obj.magic(#"3")
let hh9 = 3 == Obj.magic(#3)
let hh10 = "3" == Obj.magic(#3)
let tuple = (
nest(A(#"0")),
nest(A(#"1")),
nest(A(#"2")),
nest(B(#"1",0)),
nest(B(#"1",1)),
nest(B(#"2",1)),
nest(B(#"2",2)),
nest(B(#"0",0)),
nest(B(#"0",1)),
hh9,
hh10
nest(A(#0)),
nest(A(#1)),
nest(A(#2)),
nest(B(#1, 0)),
nest(B(#1, 1)),
nest(B(#2, 1)),
nest(B(#2, 2)),
nest(B(#0, 0)),
nest(B(#0, 1)),
hh9,
hh10,
)

let begin = 3
eq_suites(id,suites,__LOC__,hihi,3)
eq_suites(id,suites,__LOC__,tuple,(0,1,2,3,4,5,5,3,6,true,false))
let begin = 3
eq_suites(id, suites, __LOC__, hihi, 3)
eq_suites(id, suites, __LOC__, tuple, (0, 1, 2, 3, 4, 5, 5, 3, 6, true, false))

let hh0 = ( x : list<t>) => ( x :> list <int>)
let hh1 = ( x : list< [ #a | #b ]>) => ( x :> list <string>)
let hh0 = (x: list<t>) => (x :> list<int>)
let hh1 = (x: list<[#a | #b]>) => (x :> list<string>)

// let hh2 = ( x : [#a (int)]) => ( x :> string)
// let hh2 = ( x : [#a (int)]) => ( x :> int)
// let hh2 = ( x : [#a (int)]) => ( x :> string)
// let hh2 = ( x : [#a (int)]) => ( x :> int)
// let hh1 = ( x : list< [< #a | #b ]>) => ( x :> list <string>)

type t0 = [#a | #b]

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

type t0 = [#a|#b]
type u = [#0(int) | #1(string)]

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

Mt.from_pair_suites(__FILE__,suites.contents)
let f = (x: u) => {
switch x {
| #0(x) => string_of_int(x)
| #1(x) => x
}
}
Mt.from_pair_suites(__FILE__, suites.contents)
Loading