Skip to content

Commit

Permalink
Update test files of other sub-projects as well
Browse files Browse the repository at this point in the history
  • Loading branch information
chengluyu committed Dec 30, 2023
1 parent dcef2e2 commit 73b389b
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 69 deletions.
8 changes: 4 additions & 4 deletions compiler/shared/test/diff/LambLift.mls
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ fun foo() =
local(1)
foo()
//│ Parsed:
//│ TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup(), Blk(NuFunDef(Some(false), local, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(NuTypeDef(Cls, TypeName("Foo"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(App(Var("+"), Tup((N, Var("x")), (N, App(Var("foo"), Tup())))))))), Sel(Bra(rcd = false, App(NuNew(Var("Foo")), Tup())), bar))))), App(Var("local"), Tup((N, IntLit(1)))))))), App(Var("foo"), Tup()))
//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List()),Blk(List(NuFunDef(Some(false),Var(local),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(NuTypeDef(Cls,TypeName(Foo),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),App(Var(foo),Tup(List())))))))))))), Sel(Bra(false,App(NuNew(Var(Foo)),Tup(List()))),Var(bar))))))), App(Var(local),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))))))))))), App(Var(foo),Tup(List()))))
//│ Lifted:
//│ TypingUnit {
//│ class Foo$1([x,]) {fun bar = () => +((this).x, foo$1(),)}
Expand All @@ -28,7 +28,7 @@ fun foo(f) =
f(1)
foo(x => x+1)
//│ Parsed:
//│ TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("f"))), Blk(App(Var("f"), Tup((N, IntLit(1)))))))), App(Var("foo"), Tup((N, Lam(Tup((N, Var("x"))), App(Var("+"), Tup((N, Var("x")), (N, IntLit(1)))))))))
//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(f))))),Blk(List(App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))))))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))))))))))
//│ Lifted:
//│ TypingUnit {
//│ class Lambda1$2$1([]) {fun apply = (x,) => +(x, 1,)}
Expand All @@ -46,7 +46,7 @@ fun foo(x) =
bar(y => y+x)
foo(1)
//│ Parsed:
//│ TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(NuFunDef(Some(false), bar, N, Nil, L(Lam(Tup((N, Var("f"))), Blk(App(Var("f"), Tup((N, Var("x")))))))), App(Var("bar"), Tup((N, Lam(Tup((N, Var("y"))), App(Var("+"), Tup((N, Var("y")), (N, Var("x")))))))))))), App(Var("foo"), Tup((N, IntLit(1)))))
//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(NuFunDef(Some(false),Var(bar),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(f))))),Blk(List(App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))))))))), App(Var(bar),Tup(List((None,Fld(FldFlags(false,false,false),Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(y))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(y))), (None,Fld(FldFlags(false,false,false),Var(x))))))))))))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))))))))
//│ Lifted:
//│ TypingUnit {
//│ class Lambda1$3$1([x,]) {fun apply = (y,) => +(y, (this).x,)}
Expand All @@ -68,7 +68,7 @@ fun app(a) =
foo(z => a.bar(z))
app(new A(1))
//│ Parsed:
//│ TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("f"))), Blk(App(Var("f"), Tup((N, IntLit(1)))))))), NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((S(Var("y")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(Lam(Tup((N, Var("z"))), App(Var("+"), Tup((N, Var("y")), (N, Var("z"))))))))), NuFunDef(None, app, N, Nil, L(Lam(Tup((N, Var("a"))), Blk(App(Var("foo"), Tup((N, Lam(Tup((N, Var("z"))), App(Sel(Var("a"), bar), Tup((N, Var("z")))))))))))), App(Var("app"), Tup((N, App(NuNew(Var("A")), Tup((N, IntLit(1))))))))
//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(f))))),Blk(List(App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))))))))))), NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((Some(Var(y)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(z))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(y))), (None,Fld(FldFlags(false,false,false),Var(z)))))))))))), NuFunDef(None,Var(app),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(a))))),Blk(List(App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(z))))),App(Sel(Var(a),Var(bar)),Tup(List((None,Fld(FldFlags(false,false,false),Var(z))))))))))))))))), App(Var(app),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(A)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))))))))))
//│ Lifted:
//│ TypingUnit {
//│ class A$1([y: Int,]) {fun bar = (z,) => +((this).y, z,)}
Expand Down
10 changes: 5 additions & 5 deletions compiler/shared/test/diff/LiftType.mls
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class CTX{
//│ |#class| |CTX|{|→|#class| |A| |{||}|↵|#fun| |foo|(|f|#:| |A| |#=>| |A|)|#:| |(|A| |#=>| |A|)| |#=>| |A| |#=| |f|(|#new| |A|)|←|↵|}|
//│ Parsed: {class CTX {class A {}; fun foo = (f: (A,) => A,) => f(new A,) : (A -> A) -> A}}
//│ Parsed:
//│ TypingUnit(NuTypeDef(Cls, TypeName("CTX"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit()), NuFunDef(None, foo, N, Nil, L(Lam(Tup((S(Var("f")), Lam(Tup((N, Var("A"))), Var("A")))), Asc(App(Var("f"), Tup((N, NuNew(Var("A"))))), Function(Tuple(N -> Fld(N, Function(Tuple(N -> Fld(N, TypeName("A"))), TypeName("A")))), TypeName("A")))))))))
//│ TypingUnit(List(NuTypeDef(Cls,TypeName(CTX),List(),None,None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List())), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(f)),Fld(FldFlags(false,false,false),Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(A))))),Var(A)))))),Asc(App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),NuNew(Var(A))))))),Function(Tuple(List((None,Field(None,Function(Tuple(List((None,Field(None,TypeName(A))))),TypeName(A)))))),TypeName(A)))))))))))
//│ Lifted:
//│ TypingUnit {
//│ class CTX$1_A$2([par$CTX$1,]) {}
Expand All @@ -26,7 +26,7 @@ class CTX(x, y){
//│ |#class| |CTX|(|x|,| |y|)|{|→|#class| |A|{| |#fun| |foo| |#=| |x|}|↵|#class| |B|#:| |A| |{| |#fun| |foo| |#=| |y|}|↵|#fun| |foo|(|any|#:| |[|A|,| |B|]|)|#:| |[|B|,| |A|]| |#=| |[|any|._2|,| |any|._1|]|←|↵|}|
//│ Parsed: {class CTX(x, y,) {class A {fun foo = x}; class B: A {fun foo = y}; fun foo = (any: [A, B,],) => [(any)._2, (any)._1,] : [B, A]}}
//│ Parsed:
//│ TypingUnit(NuTypeDef(Cls, TypeName("CTX"), Ls(), S(Tup((N, Var("x")), (N, Var("y")))), N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Var("x"))))), NuTypeDef(Cls, TypeName("B"), Ls(), N, N, S(TypeName("A")), Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Var("y"))))), NuFunDef(None, foo, N, Nil, L(Lam(Tup((S(Var("any")), Tup((N, Var("A")), (N, Var("B"))))), Asc(Tup((N, Sel(Var("any"), _2)), (N, Sel(Var("any"), _1))), Tuple(N -> Fld(N, TypeName("B")), N -> Fld(N, TypeName("A"))))))))))
//│ TypingUnit(List(NuTypeDef(Cls,TypeName(CTX),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Var(x)))))), NuTypeDef(Cls,TypeName(B),List(),None,None,Some(TypeName(A)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Var(y)))))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(any)),Fld(FldFlags(false,false,false),Tup(List((None,Fld(FldFlags(false,false,false),Var(A))), (None,Fld(FldFlags(false,false,false),Var(B))))))))),Asc(Tup(List((None,Fld(FldFlags(false,false,false),Sel(Var(any),Var(_2)))), (None,Fld(FldFlags(false,false,false),Sel(Var(any),Var(_1)))))),Tuple(List((None,Field(None,TypeName(B))), (None,Field(None,TypeName(A))))))))))))))
//│ Lifted:
//│ TypingUnit {
//│ class CTX$1_A$2([par$CTX$1,]) {fun foo = () => ((this).par$CTX$1).x}
Expand All @@ -45,7 +45,7 @@ class CTX(x, y){
//│ |#class| |CTX|(|x|,| |y|)|{|→|#class| |A|{| |#fun| |foo| |#=| |x|}|↵|#class| |B|#:| |A| |{| |#fun| |foo| |#=| |y|}|↵|#fun| |foo|(|any|#:| |{|p1|#:| |A|,| |p2|#:| |B|}|)|#:| |[|B|,| |A|]| |#=| |[|any|.p2|,| |any|.p1|]|←|↵|}|
//│ Parsed: {class CTX(x, y,) {class A {fun foo = x}; class B: A {fun foo = y}; fun foo = (any: '{' {p1: A, p2: B} '}',) => [(any).p2, (any).p1,] : [B, A]}}
//│ Parsed:
//│ TypingUnit(NuTypeDef(Cls, TypeName("CTX"), Ls(), S(Tup((N, Var("x")), (N, Var("y")))), N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Var("x"))))), NuTypeDef(Cls, TypeName("B"), Ls(), N, N, S(TypeName("A")), Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Var("y"))))), NuFunDef(None, foo, N, Nil, L(Lam(Tup((S(Var("any")), Bra(rcd = true, Rcd(Var("p1") = Var("A"), Var("p2") = Var("B"))))), Asc(Tup((N, Sel(Var("any"), p2)), (N, Sel(Var("any"), p1))), Tuple(N -> Fld(N, TypeName("B")), N -> Fld(N, TypeName("A"))))))))))
//│ TypingUnit(List(NuTypeDef(Cls,TypeName(CTX),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Var(x)))))), NuTypeDef(Cls,TypeName(B),List(),None,None,Some(TypeName(A)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Var(y)))))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(any)),Fld(FldFlags(false,false,false),Bra(true,Rcd(List((Var(p1),Fld(FldFlags(false,false,false),Var(A))), (Var(p2),Fld(FldFlags(false,false,false),Var(B)))))))))),Asc(Tup(List((None,Fld(FldFlags(false,false,false),Sel(Var(any),Var(p2)))), (None,Fld(FldFlags(false,false,false),Sel(Var(any),Var(p1)))))),Tuple(List((None,Field(None,TypeName(B))), (None,Field(None,TypeName(A))))))))))))))
//│ Lifted:
//│ TypingUnit {
//│ class CTX$1_A$2([par$CTX$1,]) {fun foo = () => ((this).par$CTX$1).x}
Expand All @@ -64,7 +64,7 @@ class CTX(x, y){
//│ |#class| |CTX|(|x|,| |y|)|{|→|#class| |A|{| |#fun| |foo| |#=| |x|}|↵|#class| |B|‹|T|›| |{| |#fun| |foo| |#=| |y|}|↵|#fun| |foo|(|any|#:| |[|A|,| |B|‹|A|›|]|)|#:| |[|[|B|‹|A|›|,| |A|]|,| |A|]| |#=| |[|any|,| |any|._1|]|←|↵|}|
//│ Parsed: {class CTX(x, y,) {class A {fun foo = x}; class B‹T› {fun foo = y}; fun foo = (any: [A, B‹A›,],) => [any, (any)._1,] : [[B[A], A], A]}}
//│ Parsed:
//│ TypingUnit(NuTypeDef(Cls, TypeName("CTX"), Ls(), S(Tup((N, Var("x")), (N, Var("y")))), N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Var("x"))))), NuTypeDef(Cls, TypeName("B"), Ls(N -> TypeName("T")), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Var("y"))))), NuFunDef(None, foo, N, Nil, L(Lam(Tup((S(Var("any")), Tup((N, Var("A")), (N, TyApp(Var("B"), List(TypeName(A))))))), Asc(Tup((N, Var("any")), (N, Sel(Var("any"), _1))), Tuple(N -> Fld(N, Tuple(N -> Fld(N, AppliedType(TypeName("B"), TypeName("A") :: Nil)), N -> Fld(N, TypeName("A")))), N -> Fld(N, TypeName("A"))))))))))
//│ TypingUnit(List(NuTypeDef(Cls,TypeName(CTX),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Var(x)))))), NuTypeDef(Cls,TypeName(B),List((None,TypeName(T))),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Var(y)))))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(any)),Fld(FldFlags(false,false,false),Tup(List((None,Fld(FldFlags(false,false,false),Var(A))), (None,Fld(FldFlags(false,false,false),TyApp(Var(B),List(TypeName(A))))))))))),Asc(Tup(List((None,Fld(FldFlags(false,false,false),Var(any))), (None,Fld(FldFlags(false,false,false),Sel(Var(any),Var(_1)))))),Tuple(List((None,Field(None,Tuple(List((None,Field(None,AppliedType(TypeName(B),List(TypeName(A))))), (None,Field(None,TypeName(A))))))), (None,Field(None,TypeName(A))))))))))))))
//│ Lifted:
//│ TypingUnit {
//│ class CTX$1_A$2([par$CTX$1,]) {fun foo = () => ((this).par$CTX$1).x}
Expand All @@ -86,7 +86,7 @@ class CTX{
//│ |#class| |CTX|{|→|#fun| |ctx|(|x|,|y|)| |#=| |→|#class| |A|{| |#fun| |foo| |#=| |x| |}|↵|#fun| |bar|‹|T|›|(|any|#:| |T|)|#:| |A| |#=| |→|#let| |x| |#=| |#new| |T|↵|#new| |A|←|↵|(|#new| |CTX|)|.bar|‹|CTX|›|←|←|↵|}|
//│ Parsed: {class CTX {fun ctx = (x, y,) => {class A {fun foo = x}; fun bar = (any: T,) => {let x = new T; new A} : A; ('(' new CTX ')').bar‹CTX›}}}
//│ Parsed:
//│ TypingUnit(NuTypeDef(Cls, TypeName("CTX"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, ctx, N, Nil, L(Lam(Tup((N, Var("x")), (N, Var("y"))), Blk(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Var("x"))))), NuFunDef(None, bar, N, TypeName("T") :: Nil, L(Lam(Tup((S(Var("any")), Var("T"))), Asc(Blk(NuFunDef(Some(false), x, N, Nil, L(NuNew(Var("T")))), NuNew(Var("A"))), TypeName("A"))))), TyApp(Sel(Bra(rcd = false, NuNew(Var("CTX"))), bar), List(TypeName(CTX))))))))))
//│ TypingUnit(List(NuTypeDef(Cls,TypeName(CTX),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(ctx),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y))))),Blk(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Var(x)))))), NuFunDef(None,Var(bar),None,List(TypeName(T)),Left(Lam(Tup(List((Some(Var(any)),Fld(FldFlags(false,false,false),Var(T))))),Asc(Blk(List(NuFunDef(Some(false),Var(x),None,List(),Left(NuNew(Var(T)))), NuNew(Var(A)))),TypeName(A))))), TyApp(Sel(Bra(false,NuNew(Var(CTX))),Var(bar)),List(TypeName(CTX)))))))))))))
//│ Lifted:
//│ Lifting failed: mlscript.codegen.CodeGenError: Cannot find type T. Class values are not supported in lifter.
//│
Expand Down
Loading

0 comments on commit 73b389b

Please sign in to comment.