From baa6298ee3e2894ed8331fdbdc0dbd743f115ed1 Mon Sep 17 00:00:00 2001 From: Luyu Cheng Date: Wed, 20 Dec 2023 01:18:55 +0800 Subject: [PATCH 01/11] Extract the inspect function as a general utility This commit was cherry-picked from a future commit which changed many files. --- .../scala/mlscript/compiler/ClassLifter.scala | 2 +- .../scala/mlscript/compiler/Helpers.scala | 2 +- compiler/shared/test/diff/LambLift.mls | 8 +- compiler/shared/test/diff/LiftType.mls | 10 +- compiler/shared/test/diff/Lifter.mls | 30 +-- compiler/shared/test/diff/LifterBlks.mls | 36 ++-- compiler/shared/test/diff/mono.mls | 54 +++--- .../test/scala/mlscript/compiler/Test.scala | 2 +- .../src/main/scala/mlscript/JSBackend.scala | 11 +- .../main/scala/mlscript/codegen/Helpers.scala | 100 ---------- .../main/scala/mlscript/utils/inspect.scala | 182 ++++++++++++++++++ shared/src/test/diff/basics/Blocks.fun | 10 +- shared/src/test/diff/basics/Data.fun | 4 +- shared/src/test/diff/basics/Datatypes.fun | 14 +- shared/src/test/diff/basics/Either.fun | 4 +- shared/src/test/diff/basics/Flow.fun | 4 +- shared/src/test/diff/basics/Operators.fun | 16 +- shared/src/test/diff/basics/Slashes.fun | 2 +- shared/src/test/diff/mlscript/Basics.mls | 2 +- .../src/test/diff/mlscript/ByNameByValue.mls | 4 +- shared/src/test/diff/mlscript/MultiArgs.mls | 8 +- shared/src/test/diff/mlscript/Mut.mls | 2 +- shared/src/test/diff/mlscript/Ops.mls | 10 +- shared/src/test/diff/mlscript/Weird.mls | 2 +- shared/src/test/diff/nu/AbstractClasses.mls | 2 +- shared/src/test/diff/nu/BadBlocks.mls | 2 +- shared/src/test/diff/nu/LamPatterns.mls | 2 +- shared/src/test/diff/nu/LetRec.mls | 2 +- shared/src/test/diff/nu/NewNew.mls | 10 +- shared/src/test/diff/nu/OpLam.mls | 2 +- shared/src/test/diff/nu/OverrideShorthand.mls | 4 +- shared/src/test/diff/nu/RightAssocOps.mls | 6 +- shared/src/test/diff/nu/TODO_Classes.mls | 2 +- shared/src/test/diff/ucs/LeadingAnd.mls | 4 +- shared/src/test/diff/ucs/SplitOps.mls | 4 +- .../src/test/scala/mlscript/DiffTests.scala | 4 +- 36 files changed, 322 insertions(+), 241 deletions(-) delete mode 100644 shared/src/main/scala/mlscript/codegen/Helpers.scala create mode 100644 shared/src/main/scala/mlscript/utils/inspect.scala diff --git a/compiler/shared/main/scala/mlscript/compiler/ClassLifter.scala b/compiler/shared/main/scala/mlscript/compiler/ClassLifter.scala index 5124a31c5..947db768a 100644 --- a/compiler/shared/main/scala/mlscript/compiler/ClassLifter.scala +++ b/compiler/shared/main/scala/mlscript/compiler/ClassLifter.scala @@ -7,7 +7,7 @@ import scala.collection.mutable.StringBuilder as StringBuilder import scala.collection.mutable.Map as MutMap import scala.collection.mutable.Set as MutSet import scala.collection.mutable.ArrayBuffer as ArrayBuffer -import mlscript.codegen.Helpers.inspect as showStructure +import inspect.deep as showStructure import mlscript.codegen.CodeGenError import mlscript.compiler.mono.MonomorphError diff --git a/compiler/shared/main/scala/mlscript/compiler/Helpers.scala b/compiler/shared/main/scala/mlscript/compiler/Helpers.scala index 5eb1a526d..ed842b704 100644 --- a/compiler/shared/main/scala/mlscript/compiler/Helpers.scala +++ b/compiler/shared/main/scala/mlscript/compiler/Helpers.scala @@ -1,7 +1,7 @@ package mlscript package compiler -import mlscript.codegen.Helpers.inspect as showStructure +import mlscript.utils.inspect.deep as showStructure import mlscript.compiler.mono.{Monomorph, MonomorphError} import scala.collection.mutable.ArrayBuffer diff --git a/compiler/shared/test/diff/LambLift.mls b/compiler/shared/test/diff/LambLift.mls index c42974bf4..b345cbf0a 100644 --- a/compiler/shared/test/diff/LambLift.mls +++ b/compiler/shared/test/diff/LambLift.mls @@ -10,7 +10,7 @@ fun foo() = local(1) foo() //│ Parsed: -//│ TypingUnit(NuFunDef(None, foo, None, [], Lam(Tup(), Blk(...))), App(Var(foo), Tup())) +//│ 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())) //│ Lifted: //│ TypingUnit { //│ class Foo$1([x,]) {fun bar = () => +((this).x, foo$1(),)} @@ -28,7 +28,7 @@ fun foo(f) = f(1) foo(x => x+1) //│ Parsed: -//│ TypingUnit(NuFunDef(None, foo, None, [], Lam(Tup(_: Var(f)), Blk(...))), App(Var(foo), Tup(_: Lam(Tup(_: Var(x)), App(Var(+), Tup(_: Var(x), _: IntLit(1))))))) +//│ 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))))))))) //│ Lifted: //│ TypingUnit { //│ class Lambda1$2$1([]) {fun apply = (x,) => +(x, 1,)} @@ -46,7 +46,7 @@ fun foo(x) = bar(y => y+x) foo(1) //│ Parsed: -//│ TypingUnit(NuFunDef(None, foo, None, [], Lam(Tup(_: Var(x)), Blk(...))), App(Var(foo), Tup(_: IntLit(1)))) +//│ 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))))) //│ Lifted: //│ TypingUnit { //│ class Lambda1$3$1([x,]) {fun apply = (y,) => +(y, (this).x,)} @@ -68,7 +68,7 @@ fun app(a) = foo(z => a.bar(z)) app(new A(1)) //│ Parsed: -//│ TypingUnit(NuFunDef(None, foo, None, [], Lam(Tup(_: Var(f)), Blk(...))), NuTypeDef(class, A, (), Tup(y: Var(Int)), (), None, None, TypingUnit(NuFunDef(None, bar, None, [], Lam(Tup(_: Var(z)), App(Var(+), Tup(_: Var(y), _: Var(z))))))), NuFunDef(None, app, None, [], Lam(Tup(_: Var(a)), Blk(...))), App(Var(app), Tup(_: App(NuNew(Var(A)), Tup(_: IntLit(1)))))) +//│ 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)))))))) //│ Lifted: //│ TypingUnit { //│ class A$1([y: Int,]) {fun bar = (z,) => +((this).y, z,)} diff --git a/compiler/shared/test/diff/LiftType.mls b/compiler/shared/test/diff/LiftType.mls index 773e24b1e..f7a68e4d5 100644 --- a/compiler/shared/test/diff/LiftType.mls +++ b/compiler/shared/test/diff/LiftType.mls @@ -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(class, CTX, (), Tup(), (), None, None, TypingUnit(NuTypeDef(class, A, (), Tup(), (), None, None, TypingUnit()), NuFunDef(None, foo, None, [], Lam(Tup(f: Lam(Tup(_: Var(A)), Var(A))), Asc(App(Var(f), Tup(_: NuNew(Var(A)))), Function(Tuple(List((None,Field(None,Function(Tuple(List((None,Field(None,TypeName(A))))),TypeName(A)))))),TypeName(A)))))))) +//│ 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(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,]) {} @@ -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(class, CTX, (), Tup(_: Var(x), _: Var(y)), (), None, None, TypingUnit(NuTypeDef(class, A, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, foo, None, [], Var(x)))), NuTypeDef(class, B, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, foo, None, [], Var(y)))), NuFunDef(None, foo, None, [], Lam(Tup(any: Tup(_: Var(A), _: Var(B))), Asc(Tup(_: Sel(Var(any), _2), _: Sel(Var(any), _1)), Tuple(List((None,Field(None,TypeName(B))), (None,Field(None,TypeName(A))))))))))) +//│ 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(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} @@ -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(class, CTX, (), Tup(_: Var(x), _: Var(y)), (), None, None, TypingUnit(NuTypeDef(class, A, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, foo, None, [], Var(x)))), NuTypeDef(class, B, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, foo, None, [], Var(y)))), NuFunDef(None, foo, None, [], Lam(Tup(any: Bra(rcd = true, Rcd(Var(p1) = Var(A), Var(p2) = Var(B)))), Asc(Tup(_: Sel(Var(any), p2), _: Sel(Var(any), p1)), Tuple(List((None,Field(None,TypeName(B))), (None,Field(None,TypeName(A))))))))))) +//│ 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(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} @@ -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(class, CTX, (), Tup(_: Var(x), _: Var(y)), (), None, None, TypingUnit(NuTypeDef(class, A, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, foo, None, [], Var(x)))), NuTypeDef(class, B, ((None,TypeName(T))), Tup(), (), None, None, TypingUnit(NuFunDef(None, foo, None, [], Var(y)))), NuFunDef(None, foo, None, [], Lam(Tup(any: Tup(_: Var(A), _: TyApp(Var(B), List(TypeName(A))))), Asc(Tup(_: Var(any), _: Sel(Var(any), _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))))))))))) +//│ 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(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} @@ -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(class, CTX, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, ctx, None, [], Lam(Tup(_: Var(x), _: Var(y)), Blk(...)))))) +//│ 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)))))))))) //│ Lifted: //│ Lifting failed: mlscript.codegen.CodeGenError: Cannot find type T. Class values are not supported in lifter. //│ diff --git a/compiler/shared/test/diff/Lifter.mls b/compiler/shared/test/diff/Lifter.mls index fffb3d725..1486bb629 100644 --- a/compiler/shared/test/diff/Lifter.mls +++ b/compiler/shared/test/diff/Lifter.mls @@ -28,7 +28,7 @@ class A(x) { //│ |#class| |A|(|x|)| |{|→|#class| |B|(|y|)| |{|→|#fun| |getX| |#=| |x|↵|#fun| |getB1| |#=| |B1|(|y|)|↵|#class| |C|(|z|)| |{|→|#fun| |inc|(||)| |#=| |x| |+| |1|↵|#fun| |getY| |#=| |y|↵|#fun| |getA| |#=| |A|(|z|)|↵|#fun| |getB|(|w|)| |#=| |B|(|w|)|↵|#fun| |getC| |#=| |#new| |C|(|inc|(||)|)|↵|#fun| |getSelf| |#=| |this|←|↵|}|←|↵|}|↵|#class| |B1|(|y|)| |{|→|#fun| |getX| |#=| |x|↵|#fun| |getY| |#=| |y|↵|#fun| |getB| |#=| |#new| |B|(|y|)|↵|#fun| |getB1| |#=| |#new| |B1|(|y|)|←|↵|}|↵|#fun| |getB| |#=| |#new| |B|(|x|)|↵|#fun| |getB2|(|y|)| |#=| |B1|(|y|)|↵|#fun| |getB3|(|z|)| |#=| |getB2|(|z|)|↵|#fun| |getA| |#=| |A|(|x|)|←|↵|}| //│ Parsed: {class A(x,) {class B(y,) {fun getX = x; fun getB1 = B1(y,); class C(z,) {fun inc = () => +(x, 1,); fun getY = y; fun getA = A(z,); fun getB = (w,) => B(w,); fun getC = (new C)(inc(),); fun getSelf = this}}; class B1(y,) {fun getX = x; fun getY = y; fun getB = (new B)(y,); fun getB1 = (new B1)(y,)}; fun getB = (new B)(x,); fun getB2 = (y,) => B1(y,); fun getB3 = (z,) => getB2(z,); fun getA = A(x,)}} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, A, (), Tup(_: Var(x)), (), None, None, TypingUnit(NuTypeDef(class, B, (), Tup(_: Var(y)), (), None, None, TypingUnit(NuFunDef(None, getX, None, [], Var(x)), NuFunDef(None, getB1, None, [], App(Var(B1), Tup(_: Var(y)))), NuTypeDef(class, C, (), Tup(_: Var(z)), (), None, None, TypingUnit(NuFunDef(None, inc, None, [], Lam(Tup(), App(Var(+), Tup(_: Var(x), _: IntLit(1))))), NuFunDef(None, getY, None, [], Var(y)), NuFunDef(None, getA, None, [], App(Var(A), Tup(_: Var(z)))), NuFunDef(None, getB, None, [], Lam(Tup(_: Var(w)), App(Var(B), Tup(_: Var(w))))), NuFunDef(None, getC, None, [], App(NuNew(Var(C)), Tup(_: App(Var(inc), Tup())))), NuFunDef(None, getSelf, None, [], Var(this)))))), NuTypeDef(class, B1, (), Tup(_: Var(y)), (), None, None, TypingUnit(NuFunDef(None, getX, None, [], Var(x)), NuFunDef(None, getY, None, [], Var(y)), NuFunDef(None, getB, None, [], App(NuNew(Var(B)), Tup(_: Var(y)))), NuFunDef(None, getB1, None, [], App(NuNew(Var(B1)), Tup(_: Var(y)))))), NuFunDef(None, getB, None, [], App(NuNew(Var(B)), Tup(_: Var(x)))), NuFunDef(None, getB2, None, [], Lam(Tup(_: Var(y)), App(Var(B1), Tup(_: Var(y))))), NuFunDef(None, getB3, None, [], Lam(Tup(_: Var(z)), App(Var(getB2), Tup(_: Var(z))))), NuFunDef(None, getA, None, [], App(Var(A), Tup(_: Var(x))))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), S(Tup((N, Var("y")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, getX, N, Nil, L(Var("x"))), NuFunDef(None, getB1, N, Nil, L(App(Var("B1"), Tup((N, Var("y")))))), NuTypeDef(Cls, TypeName("C"), Ls(), S(Tup((N, Var("z")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, inc, N, Nil, L(Lam(Tup(), App(Var("+"), Tup((N, Var("x")), (N, IntLit(1))))))), NuFunDef(None, getY, N, Nil, L(Var("y"))), NuFunDef(None, getA, N, Nil, L(App(Var("A"), Tup((N, Var("z")))))), NuFunDef(None, getB, N, Nil, L(Lam(Tup((N, Var("w"))), App(Var("B"), Tup((N, Var("w"))))))), NuFunDef(None, getC, N, Nil, L(App(NuNew(Var("C")), Tup((N, App(Var("inc"), Tup())))))), NuFunDef(None, getSelf, N, Nil, L(Var("this"))))))), NuTypeDef(Cls, TypeName("B1"), Ls(), S(Tup((N, Var("y")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, getX, N, Nil, L(Var("x"))), NuFunDef(None, getY, N, Nil, L(Var("y"))), NuFunDef(None, getB, N, Nil, L(App(NuNew(Var("B")), Tup((N, Var("y")))))), NuFunDef(None, getB1, N, Nil, L(App(NuNew(Var("B1")), Tup((N, Var("y")))))))), NuFunDef(None, getB, N, Nil, L(App(NuNew(Var("B")), Tup((N, Var("x")))))), NuFunDef(None, getB2, N, Nil, L(Lam(Tup((N, Var("y"))), App(Var("B1"), Tup((N, Var("y"))))))), NuFunDef(None, getB3, N, Nil, L(Lam(Tup((N, Var("z"))), App(Var("getB2"), Tup((N, Var("z"))))))), NuFunDef(None, getA, N, Nil, L(App(Var("A"), Tup((N, Var("x"))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2_C$4([par$A$1_B$2, z, x,]) { @@ -68,7 +68,7 @@ class A(x) { //│ |#class| |A|(|x|)| |{|→|#class| |B|(|y|)| |{|→|#class| |C|(|z|)| |{|→|#fun| |sum| |#=| |x| |+| |y| |+| |z|←|↵|}|←|↵|}|←|↵|}| //│ Parsed: {class A(x,) {class B(y,) {class C(z,) {fun sum = +(+(x, y,), z,)}}}} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, A, (), Tup(_: Var(x)), (), None, None, TypingUnit(NuTypeDef(class, B, (), Tup(_: Var(y)), (), None, None, TypingUnit(NuTypeDef(class, C, (), Tup(_: Var(z)), (), None, None, TypingUnit(NuFunDef(None, sum, None, [], App(Var(+), Tup(_: App(Var(+), Tup(_: Var(x), _: Var(y))), _: Var(z))))))))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), S(Tup((N, Var("y")))), N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("C"), Ls(), S(Tup((N, Var("z")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, sum, N, Nil, L(App(Var("+"), Tup((N, App(Var("+"), Tup((N, Var("x")), (N, Var("y"))))), (N, Var("z"))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2_C$3([par$A$1_B$2, z, x,]) { @@ -108,7 +108,7 @@ new C{ //│ |#class| |A|(|x|)| |{|→|#class| |B|{|→|#fun| |foo| |#=| |1|↵|#fun| |bar| |#=| |11|←|↵|}|↵|#fun| |getB| |#=| |#new| |B|{|→|#fun| |foo| |#=| |2|↵|#fun| |bar| |#=| |12|←|↵|}|↵|#fun| |bar| |#=| |13|←|↵|}|↵|#class| |C|#:| |A|{|→|#fun| |getB| |#=| |#new| |B|{|→|#fun| |foo| |#=| |3|↵|#fun| |bar| |#=| |14|←|↵|}|↵|#fun| |bar| |#=| |15|←|↵|}|↵|#new| |C|{|→|#fun| |getB| |#=| |#new| |B|{|→|#fun| |foo| |#=| |4|↵|#fun| |bar| |#=| |16|←|↵|}|↵|#fun| |bar| |#=| |17|←|↵|}| //│ Parsed: {class A(x,) {class B {fun foo = 1; fun bar = 11}; fun getB = new B { ‹fun foo = 2; fun bar = 12› }; fun bar = 13}; class C: A {fun getB = new B { ‹fun foo = 3; fun bar = 14› }; fun bar = 15}; new C { ‹fun getB = new B { ‹fun foo = 4; fun bar = 16› }; fun bar = 17› }} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, A, (), Tup(_: Var(x)), (), None, None, TypingUnit(NuTypeDef(class, B, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, foo, None, [], IntLit(1)), NuFunDef(None, bar, None, [], IntLit(11)))), NuFunDef(None, getB, None, [], Rft(NuNew(Var(B)), ...)), NuFunDef(None, bar, None, [], IntLit(13)))), NuTypeDef(class, C, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, getB, None, [], Rft(NuNew(Var(B)), ...)), NuFunDef(None, bar, None, [], IntLit(15)))), Rft(NuNew(Var(C)), ...)) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(1))), NuFunDef(None, bar, N, Nil, L(IntLit(11))))), NuFunDef(None, getB, N, Nil, L(Rft(NuNew(Var("B")), TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(2))), NuFunDef(None, bar, N, Nil, L(IntLit(12))))))), NuFunDef(None, bar, N, Nil, L(IntLit(13))))), NuTypeDef(Cls, TypeName("C"), Ls(), N, N, S(TypeName("A")), Ls(), N, N, TypingUnit(NuFunDef(None, getB, N, Nil, L(Rft(NuNew(Var("B")), TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(3))), NuFunDef(None, bar, N, Nil, L(IntLit(14))))))), NuFunDef(None, bar, N, Nil, L(IntLit(15))))), Rft(NuNew(Var("C")), TypingUnit(NuFunDef(None, getB, N, Nil, L(Rft(NuNew(Var("B")), TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(4))), NuFunDef(None, bar, N, Nil, L(IntLit(16))))))), NuFunDef(None, bar, N, Nil, L(IntLit(17)))))) //│ Lifted: //│ Lifting failed: mlscript.codegen.CodeGenError: Cannot find type B. Class values are not supported in lifter. //│ @@ -125,7 +125,7 @@ class Parent(x) { //│ |#class| |Parent|‹|T|,| |U|,| |V|›|(|x|)| |{| |→|#fun| |foo|(|x|#:| |Int|)|#:| |T| |#=| |x|+|1|↵|#class| |Inner|‹|W|›|(|y|#:| |Int|)|{|→|#fun| |bar|(|z|#:| |U|)| |#=| |foo|(|y|)|↵|#fun| |boo|(|z|#:| |W|)| |#=| |z|←|↵|}|←|↵|}| //│ Parsed: {class Parent‹T, U, V›(x,) {fun foo = (x: Int,) => +(x, 1,) : T; class Inner‹W›(y: Int,) {fun bar = (z: U,) => foo(y,); fun boo = (z: W,) => z}}} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, Parent, ((None,TypeName(T)), (None,TypeName(U)), (None,TypeName(V))), Tup(_: Var(x)), (), None, None, TypingUnit(NuFunDef(None, foo, None, [], Lam(Tup(x: Var(Int)), Asc(App(Var(+), Tup(_: Var(x), _: IntLit(1))), TypeName(T)))), NuTypeDef(class, Inner, ((None,TypeName(W))), Tup(y: Var(Int)), (), None, None, TypingUnit(NuFunDef(None, bar, None, [], Lam(Tup(z: Var(U)), App(Var(foo), Tup(_: Var(y))))), NuFunDef(None, boo, None, [], Lam(Tup(z: Var(W)), Var(z)))))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("Parent"), Ls(N -> TypeName("T"), N -> TypeName("U"), N -> TypeName("V")), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup((S(Var("x")), Var("Int"))), Asc(App(Var("+"), Tup((N, Var("x")), (N, IntLit(1)))), TypeName(T))))), NuTypeDef(Cls, TypeName("Inner"), Ls(N -> TypeName("W")), S(Tup((S(Var("y")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(Lam(Tup((S(Var("z")), Var("U"))), App(Var("foo"), Tup((N, Var("y"))))))), NuFunDef(None, boo, N, Nil, L(Lam(Tup((S(Var("z")), Var("W"))), Var("z"))))))))) //│ Lifted: //│ TypingUnit { //│ class Parent$1_Inner$2[W,U]([par$Parent$1, y: Int,]) { @@ -148,7 +148,7 @@ class A(x: Int): ({a1: Int} & B & D(x)) { //│ |#class| |B|‹|T|›| |{||}|↵|#class| |C| |{||}|↵|#class| |D|(|y|#:| |Int|)| |{||}|↵|#class| |A|‹|T|,| |U|›|(|x|#:| |Int|)|#:| |(|{|a1|#:| |Int|}| |&| |B|‹|T|›| |&| |D|(|x|)|)| |{|→|#fun| |getA|(||)| |#=| |#new| |C|{|→|#fun| |foo|(|x|#:| |T|)| |#=| |x|←|↵|}|←|↵|}| //│ Parsed: {class B‹T› {}; class C {}; class D(y: Int,) {}; class A‹T, U›(x: Int,): {a1: Int} & B[T] & D[x] {fun getA = () => new C { ‹fun foo = (x: T,) => x› }}} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, B, ((None,TypeName(T))), Tup(), (), None, None, TypingUnit()), NuTypeDef(class, C, (), Tup(), (), None, None, TypingUnit()), NuTypeDef(class, D, (), Tup(y: Var(Int)), (), None, None, TypingUnit()), NuTypeDef(class, A, ((None,TypeName(T)), (None,TypeName(U))), Tup(x: Var(Int)), (), None, None, TypingUnit(NuFunDef(None, getA, None, [], Lam(Tup(), Rft(NuNew(Var(C)), ...)))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(N -> TypeName("T")), N, N, N, Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("C"), Ls(), N, N, N, Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("D"), Ls(), S(Tup((S(Var("y")), Var("Int")))), N, N, Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("A"), Ls(N -> TypeName("T"), N -> TypeName("U")), S(Tup((S(Var("x")), Var("Int")))), N, S(Inter(Inter(Record(a1: Fld(N, TypeName("Int"))), AppliedType(TypeName("B"), TypeName("T") :: Nil)), AppliedType(TypeName("D"), TypeName("x") :: Nil))), Ls(), N, N, TypingUnit(NuFunDef(None, getA, N, Nil, L(Lam(Tup(), Rft(NuNew(Var("C")), TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup((S(Var("x")), Var("T"))), Var("x")))))))))))) //│ Lifted: //│ TypingUnit { //│ class B$1[T]([]) {} @@ -170,7 +170,7 @@ class A(x: Int) extends {a1: Int}, B, D(x){ //│ |#class| |B|‹|T|›| |{||}|↵|#class| |C| |{||}|↵|#class| |D|(|y|#:| |Int|)| |{||}|↵|#class| |A|‹|T|,| |U|›|(|x|#:| |Int|)| |#extends| |{|a1|#:| |Int|}|,| |B|‹|T|›|,| |D|(|x|)|{|→|#fun| |getA|(||)| |#=| |#new| |C|{|→|#fun| |foo|(|x|)| |#=| |x|←|↵|}|←|↵|}| //│ Parsed: {class B‹T› {}; class C {}; class D(y: Int,) {}; class A‹T, U›(x: Int,): '{' {a1: Int} '}', B‹T›, D(x,) {fun getA = () => new C { ‹fun foo = (x,) => x› }}} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, B, ((None,TypeName(T))), Tup(), (), None, None, TypingUnit()), NuTypeDef(class, C, (), Tup(), (), None, None, TypingUnit()), NuTypeDef(class, D, (), Tup(y: Var(Int)), (), None, None, TypingUnit()), NuTypeDef(class, A, ((None,TypeName(T)), (None,TypeName(U))), Tup(x: Var(Int)), (Bra(rcd = true, Rcd(Var(a1) = Var(Int))), TyApp(Var(B), List(TypeName(T))), App(Var(D), Tup(_: Var(x)))), None, None, TypingUnit(NuFunDef(None, getA, None, [], Lam(Tup(), Rft(NuNew(Var(C)), ...)))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(N -> TypeName("T")), N, N, N, Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("C"), Ls(), N, N, N, Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("D"), Ls(), S(Tup((S(Var("y")), Var("Int")))), N, N, Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("A"), Ls(N -> TypeName("T"), N -> TypeName("U")), S(Tup((S(Var("x")), Var("Int")))), N, N, Ls(Bra(rcd = true, Rcd(Var("a1") = Var("Int"))), TyApp(Var("B"), List(TypeName(T))), App(Var("D"), Tup((N, Var("x"))))), N, N, TypingUnit(NuFunDef(None, getA, N, Nil, L(Lam(Tup(), Rft(NuNew(Var("C")), TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("x"))), Var("x")))))))))))) //│ Lifted: //│ TypingUnit { //│ class B$1[T]([]) {} @@ -190,7 +190,7 @@ class Child(x): ({ age: T } & { name: String}) { //│ |#class| |Child|‹|T|,| |U|›|(|x|)|#:| |(|{| |age|#:| |T| |}| |&| |{| |name|#:| |String|}|)| |{|→|#class| |Inner|{|→|#fun| |foo| |#=| |age|←|↵|}|↵|#fun| |bar| |#=| |age|↵|#fun| |boo| |#=| |#new| |Inner|←|↵|}| //│ Parsed: {class Child‹T, U›(x,): {age: T} & {name: String} {class Inner {fun foo = age}; fun bar = age; fun boo = new Inner}} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, Child, ((None,TypeName(T)), (None,TypeName(U))), Tup(_: Var(x)), (), None, None, TypingUnit(NuTypeDef(class, Inner, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, foo, None, [], Var(age)))), NuFunDef(None, bar, None, [], Var(age)), NuFunDef(None, boo, None, [], NuNew(Var(Inner)))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("Child"), Ls(N -> TypeName("T"), N -> TypeName("U")), S(Tup((N, Var("x")))), N, S(Inter(Record(age: Fld(N, TypeName("T"))), Record(name: Fld(N, TypeName("String"))))), Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("Inner"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Var("age"))))), NuFunDef(None, bar, N, Nil, L(Var("age"))), NuFunDef(None, boo, N, Nil, L(NuNew(Var("Inner"))))))) //│ Lifted: //│ TypingUnit { //│ class Child$1_Inner$2([par$Child$1, age,]) {fun foo = () => (this).age} @@ -213,7 +213,7 @@ new A(0) { //│ |#class| |A|(|x|#:| |Int|)| |{|→|#fun| |getA|#:| |Int| |#=| |0|↵|#fun| |getA1| |#=| |1|←|↵|}|↵|#new| |A|(|0|)| |{|→|#fun| |getA| |#=| |3|↵|#fun| |getA2| |#=| |2|←|↵|}| //│ Parsed: {class A(x: Int,) {fun getA = 0 : Int; fun getA1 = 1}; (new A)(0,) { ‹fun getA = 3; fun getA2 = 2› }} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, A, (), Tup(x: Var(Int)), (), None, None, TypingUnit(NuFunDef(None, getA, None, [], Asc(IntLit(0), TypeName(Int))), NuFunDef(None, getA1, None, [], IntLit(1)))), Rft(App(NuNew(Var(A)), Tup(_: IntLit(0))), ...)) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((S(Var("x")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, getA, N, Nil, L(Asc(IntLit(0), TypeName(Int)))), NuFunDef(None, getA1, N, Nil, L(IntLit(1))))), Rft(App(NuNew(Var("A")), Tup((N, IntLit(0)))), TypingUnit(NuFunDef(None, getA, N, Nil, L(IntLit(3))), NuFunDef(None, getA2, N, Nil, L(IntLit(2)))))) //│ Lifted: //│ TypingUnit { //│ class A$1([x: Int,]) {fun getA = () => 0 : Int; fun getA1 = () => 1} @@ -234,7 +234,7 @@ new A(1) { //│ |#class| |A|(|x|)| |{|→|#class| |B|(|y|)| |{| |}|←|↵|}|↵|#new| |A|(|1|)| |{|→|#fun| |getB| |#=| |#new| |B|(|2|)|{|→|#fun| |getB| |#=| |#new| |B|(|3|)|←|↵|}|←|↵|}| //│ Parsed: {class A(x,) {class B(y,) {}}; (new A)(1,) { ‹fun getB = (new B)(2,) { ‹fun getB = (new B)(3,)› }› }} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, A, (), Tup(_: Var(x)), (), None, None, TypingUnit(NuTypeDef(class, B, (), Tup(_: Var(y)), (), None, None, TypingUnit()))), Rft(App(NuNew(Var(A)), Tup(_: IntLit(1))), ...)) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), S(Tup((N, Var("y")))), N, N, Ls(), N, N, TypingUnit()))), Rft(App(NuNew(Var("A")), Tup((N, IntLit(1)))), TypingUnit(NuFunDef(None, getB, N, Nil, L(Rft(App(NuNew(Var("B")), Tup((N, IntLit(2)))), TypingUnit(NuFunDef(None, getB, N, Nil, L(App(NuNew(Var("B")), Tup((N, IntLit(3))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1, y,]) {} @@ -267,7 +267,7 @@ new B{ //│ |#class| |A| |{|→|#fun| |getA| |#=| |0|↵|#fun| |funcA| |#=| |10|←|↵|}|↵|#class| |B|#:| |A|{|→|#fun| |getA| |#=| |1|↵|#fun| |funcB| |#=| |11|←|↵|}|↵|#new| |A|↵|#new| |B|↵|#fun| |f|(|x|)| |#=| |#if| |x| |is| |A| |#then| |0| |#else| |1|↵|f|(|#new| |A|{|→|#fun| |getA| |#=| |2|←|↵|}|)|↵|#new| |B|{|→|#fun| |getA| |#=| |funcB|←|↵|}| //│ Parsed: {class A {fun getA = 0; fun funcA = 10}; class B: A {fun getA = 1; fun funcB = 11}; new A; new B; fun f = (x,) => if (is(x, A,)) then 0 else 1; f(new A { ‹fun getA = 2› },); new B { ‹fun getA = funcB› }} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, A, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, getA, None, [], IntLit(0)), NuFunDef(None, funcA, None, [], IntLit(10)))), NuTypeDef(class, B, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, getA, None, [], IntLit(1)), NuFunDef(None, funcB, None, [], IntLit(11)))), NuNew(Var(A)), NuNew(Var(B)), NuFunDef(None, f, None, [], Lam(Tup(_: Var(x)), If(IfThen(App(Var(is), Tup(_: Var(x), _: Var(A))), IntLit(0), Some(IntLit(1))))), App(Var(f), Tup(_: Rft(NuNew(Var(A)), ...))), Rft(NuNew(Var(B)), ...)) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, getA, N, Nil, L(IntLit(0))), NuFunDef(None, funcA, N, Nil, L(IntLit(10))))), NuTypeDef(Cls, TypeName("B"), Ls(), N, N, S(TypeName("A")), Ls(), N, N, TypingUnit(NuFunDef(None, getA, N, Nil, L(IntLit(1))), NuFunDef(None, funcB, N, Nil, L(IntLit(11))))), NuNew(Var("A")), NuNew(Var("B")), NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x"))), If(IfThen(App(Var("is"), Tup((N, Var("x")), (N, Var("A")))), IntLit(0), Some(IntLit(1)))))), App(Var("f"), Tup((N, Rft(NuNew(Var("A")), TypingUnit(NuFunDef(None, getA, N, Nil, L(IntLit(2)))))))), Rft(NuNew(Var("B")), TypingUnit(NuFunDef(None, getA, N, Nil, L(Var("funcB")))))) //│ Lifted: //│ TypingUnit { //│ class A$1([]) {fun getA = () => 0; fun funcA = () => 10} @@ -306,7 +306,7 @@ class A{ //│ |#class| |A|{|→|#class| |B|{|→|#fun| |funB| |#=| |1|↵|#fun| |foo| |#=| |100|←|↵|}|↵|#class| |C|#:| |B|{|→|#fun| |funC| |#=| |2|↵|#fun| |foo| |#=| |1000|←|↵|}|↵|#class| |D|{|→|#fun| |funD| |#=| |3|↵|#fun| |foo| |#=| |10000| |↵|#class| |E|#:| |C|{|→|#fun| |funE| |#=| |4|↵|#fun| |foo| |#=| |100000|←|↵|}|↵|#class| |F|#:| |E|{|→|#fun| |funF| |#=| |5|↵|#fun| |foo| |#=| |1000000|←|↵|}|←|↵|}|←|↵|}| //│ Parsed: {class A {class B {fun funB = 1; fun foo = 100}; class C: B {fun funC = 2; fun foo = 1000}; class D {fun funD = 3; fun foo = 10000; class E: C {fun funE = 4; fun foo = 100000}; class F: E {fun funF = 5; fun foo = 1000000}}}} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, A, (), Tup(), (), None, None, TypingUnit(NuTypeDef(class, B, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, funB, None, [], IntLit(1)), NuFunDef(None, foo, None, [], IntLit(100)))), NuTypeDef(class, C, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, funC, None, [], IntLit(2)), NuFunDef(None, foo, None, [], IntLit(1000)))), NuTypeDef(class, D, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, funD, None, [], IntLit(3)), NuFunDef(None, foo, None, [], IntLit(10000)), NuTypeDef(class, E, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, funE, None, [], IntLit(4)), NuFunDef(None, foo, None, [], IntLit(100000)))), NuTypeDef(class, F, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, funF, None, [], IntLit(5)), NuFunDef(None, foo, None, [], IntLit(1000000))))))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, funB, N, Nil, L(IntLit(1))), NuFunDef(None, foo, N, Nil, L(IntLit(100))))), NuTypeDef(Cls, TypeName("C"), Ls(), N, N, S(TypeName("B")), Ls(), N, N, TypingUnit(NuFunDef(None, funC, N, Nil, L(IntLit(2))), NuFunDef(None, foo, N, Nil, L(IntLit(1000))))), NuTypeDef(Cls, TypeName("D"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, funD, N, Nil, L(IntLit(3))), NuFunDef(None, foo, N, Nil, L(IntLit(10000))), NuTypeDef(Cls, TypeName("E"), Ls(), N, N, S(TypeName("C")), Ls(), N, N, TypingUnit(NuFunDef(None, funE, N, Nil, L(IntLit(4))), NuFunDef(None, foo, N, Nil, L(IntLit(100000))))), NuTypeDef(Cls, TypeName("F"), Ls(), N, N, S(TypeName("E")), Ls(), N, N, TypingUnit(NuFunDef(None, funF, N, Nil, L(IntLit(5))), NuFunDef(None, foo, N, Nil, L(IntLit(1000000)))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1,]) {fun funB = () => 1; fun foo = () => 100} @@ -349,7 +349,7 @@ class A{ //│ |#class| |A|{|→|#class| |B|{|→|#fun| |funB| |#=| |1|↵|#fun| |foo| |#=| |100|←|↵|}|↵|#class| |C|#:| |B|{|→|#fun| |funC| |#=| |2|↵|#fun| |foo| |#=| |1000|↵|#fun| |getB| |#=| |#new| |B|←|↵|}|↵|#class| |D|{|→|#fun| |funD| |#=| |3|↵|#fun| |foo| |#=| |10000| |↵|#class| |E|#:| |C|{|→|#fun| |funE| |#=| |4|↵|#fun| |foo| |#=| |100000|↵|#fun| |getD| |#=| |#new| |D|←|↵|}|↵|#class| |F|#:| |E|{|→|#fun| |funF| |#=| |5|↵|#fun| |foo| |#=| |1000000|↵|#fun| |getE| |#=| |#new| |E|{|→|#fun| |foo| |#=| |0|←|↵|}|←|↵|}|←|↵|}|←|↵|}| //│ Parsed: {class A {class B {fun funB = 1; fun foo = 100}; class C: B {fun funC = 2; fun foo = 1000; fun getB = new B}; class D {fun funD = 3; fun foo = 10000; class E: C {fun funE = 4; fun foo = 100000; fun getD = new D}; class F: E {fun funF = 5; fun foo = 1000000; fun getE = new E { ‹fun foo = 0› }}}}} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, A, (), Tup(), (), None, None, TypingUnit(NuTypeDef(class, B, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, funB, None, [], IntLit(1)), NuFunDef(None, foo, None, [], IntLit(100)))), NuTypeDef(class, C, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, funC, None, [], IntLit(2)), NuFunDef(None, foo, None, [], IntLit(1000)), NuFunDef(None, getB, None, [], NuNew(Var(B))))), NuTypeDef(class, D, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, funD, None, [], IntLit(3)), NuFunDef(None, foo, None, [], IntLit(10000)), NuTypeDef(class, E, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, funE, None, [], IntLit(4)), NuFunDef(None, foo, None, [], IntLit(100000)), NuFunDef(None, getD, None, [], NuNew(Var(D))))), NuTypeDef(class, F, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, funF, None, [], IntLit(5)), NuFunDef(None, foo, None, [], IntLit(1000000)), NuFunDef(None, getE, None, [], Rft(NuNew(Var(E)), ...))))))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, funB, N, Nil, L(IntLit(1))), NuFunDef(None, foo, N, Nil, L(IntLit(100))))), NuTypeDef(Cls, TypeName("C"), Ls(), N, N, S(TypeName("B")), Ls(), N, N, TypingUnit(NuFunDef(None, funC, N, Nil, L(IntLit(2))), NuFunDef(None, foo, N, Nil, L(IntLit(1000))), NuFunDef(None, getB, N, Nil, L(NuNew(Var("B")))))), NuTypeDef(Cls, TypeName("D"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, funD, N, Nil, L(IntLit(3))), NuFunDef(None, foo, N, Nil, L(IntLit(10000))), NuTypeDef(Cls, TypeName("E"), Ls(), N, N, S(TypeName("C")), Ls(), N, N, TypingUnit(NuFunDef(None, funE, N, Nil, L(IntLit(4))), NuFunDef(None, foo, N, Nil, L(IntLit(100000))), NuFunDef(None, getD, N, Nil, L(NuNew(Var("D")))))), NuTypeDef(Cls, TypeName("F"), Ls(), N, N, S(TypeName("E")), Ls(), N, N, TypingUnit(NuFunDef(None, funF, N, Nil, L(IntLit(5))), NuFunDef(None, foo, N, Nil, L(IntLit(1000000))), NuFunDef(None, getE, N, Nil, L(Rft(NuNew(Var("E")), TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(0)))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1,]) {fun funB = () => 1; fun foo = () => 100} @@ -384,7 +384,7 @@ new A //│ |#class| |A|{|→|#class| |B|{|→|#fun| |foo| |#=| |1|←|↵|}|↵|#fun| |bar| |#=| |#new| |B|←|↵|}|↵|#new| |A| //│ Parsed: {class A {class B {fun foo = 1}; fun bar = new B}; new A} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, A, (), Tup(), (), None, None, TypingUnit(NuTypeDef(class, B, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, foo, None, [], IntLit(1)))), NuFunDef(None, bar, None, [], NuNew(Var(B))))), NuNew(Var(A))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(1))))), NuFunDef(None, bar, N, Nil, L(NuNew(Var("B")))))), NuNew(Var("A"))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1,]) {fun foo = () => 1} @@ -409,7 +409,7 @@ let x = new A{ //│ |#class| |A|(|x|)| |{|→|#fun| |foo| |#=| |0|↵|#fun| |bar| |#=| |x|←|↵|}|↵|#let| |x| |#=| |#new| |A|{|→|#fun| |foo| |#=| |1|↵|#fun| |newFun| |#=| |2|↵|#fun| |bar| |#=| |#new| |A|(|foo|)|{|→|#fun| |foo| |#=| |bar| |+| |1|↵|#fun| |bar2| |#=| |newFun| |+| |1|←|↵|}|←|↵|}| //│ Parsed: {class A(x,) {fun foo = 0; fun bar = x}; let x = new A { ‹fun foo = 1; fun newFun = 2; fun bar = (new A)(foo,) { ‹fun foo = +(bar, 1,); fun bar2 = +(newFun, 1,)› }› }} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, A, (), Tup(_: Var(x)), (), None, None, TypingUnit(NuFunDef(None, foo, None, [], IntLit(0)), NuFunDef(None, bar, None, [], Var(x)))), NuFunDef(Some(false), x, None, [], Rft(NuNew(Var(A)), ...))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(0))), NuFunDef(None, bar, N, Nil, L(Var("x"))))), NuFunDef(Some(false), x, N, Nil, L(Rft(NuNew(Var("A")), TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(1))), NuFunDef(None, newFun, N, Nil, L(IntLit(2))), NuFunDef(None, bar, N, Nil, L(Rft(App(NuNew(Var("A")), Tup((N, Var("foo")))), TypingUnit(NuFunDef(None, foo, N, Nil, L(App(Var("+"), Tup((N, Var("bar")), (N, IntLit(1)))))), NuFunDef(None, bar2, N, Nil, L(App(Var("+"), Tup((N, Var("newFun")), (N, IntLit(1))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1([x,]) {fun foo = () => 0; fun bar = () => (this).x} @@ -437,7 +437,7 @@ new A{ //│ |#class| |A| |{||}|↵|#new| |A|{|→|#fun| |foo| |#=| |1|↵|#fun| |bar| |#=| |#new| |A|{|→|#fun| |foo1| |#=| |foo|↵|#fun| |bar1| |#=| |#new| |A|{|→|#fun| |foo2| |#=| |foo|↵|#fun| |bar2| |#=| |#new| |A|{|→|#fun| |foo3| |#=| |foo|↵|#fun| |bar3| |#=| |#new| |A|{|→|#fun| |foo4| |#=| |foo|↵|#fun| |bar4| |#=| |0|←|↵|}|←|↵|}|←|↵|}|←|↵|}|←|↵|}| //│ Parsed: {class A {}; new A { ‹fun foo = 1; fun bar = new A { ‹fun foo1 = foo; fun bar1 = new A { ‹fun foo2 = foo; fun bar2 = new A { ‹fun foo3 = foo; fun bar3 = new A { ‹fun foo4 = foo; fun bar4 = 0› }› }› }› }› }} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, A, (), Tup(), (), None, None, TypingUnit()), Rft(NuNew(Var(A)), ...)) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit()), Rft(NuNew(Var("A")), TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(1))), NuFunDef(None, bar, N, Nil, L(Rft(NuNew(Var("A")), TypingUnit(NuFunDef(None, foo1, N, Nil, L(Var("foo"))), NuFunDef(None, bar1, N, Nil, L(Rft(NuNew(Var("A")), TypingUnit(NuFunDef(None, foo2, N, Nil, L(Var("foo"))), NuFunDef(None, bar2, N, Nil, L(Rft(NuNew(Var("A")), TypingUnit(NuFunDef(None, foo3, N, Nil, L(Var("foo"))), NuFunDef(None, bar3, N, Nil, L(Rft(NuNew(Var("A")), TypingUnit(NuFunDef(None, foo4, N, Nil, L(Var("foo"))), NuFunDef(None, bar4, N, Nil, L(IntLit(0)))))))))))))))))))))) //│ Lifted: //│ TypingUnit {class A$1([]) {}; Code(List(new A$1([]) {}))} //│ diff --git a/compiler/shared/test/diff/LifterBlks.mls b/compiler/shared/test/diff/LifterBlks.mls index 414d4109b..28ebd4467 100644 --- a/compiler/shared/test/diff/LifterBlks.mls +++ b/compiler/shared/test/diff/LifterBlks.mls @@ -7,7 +7,7 @@ fun foo = //│ |#fun| |foo| |#=|→|print|(|"ok"|)|↵|print|(|"ko"|)|←| //│ Parsed: {fun foo = {print("ok",); print("ko",)}} //│ Parsed: -//│ TypingUnit(NuFunDef(None, foo, None, [], Blk(...))) +//│ TypingUnit(NuFunDef(None, foo, N, Nil, L(Blk(App(Var("print"), Tup((N, StrLit(ok)))), App(Var("print"), Tup((N, StrLit(ko)))))))) //│ Lifted: //│ TypingUnit {fun foo$1 = () => {print("ok",); print("ko",)}} //│ @@ -19,7 +19,7 @@ class A{ //│ |#class| |A|{|→|#class| |B| |{||}|↵|#fun| |foo|(|x|#:| |B|)| |#=| |(|x| |#:| |B|)|←|↵|}| //│ Parsed: {class A {class B {}; fun foo = (x: B,) => '(' x : B ')'}} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, A, (), Tup(), (), None, None, TypingUnit(NuTypeDef(class, B, (), Tup(), (), None, None, TypingUnit()), NuFunDef(None, foo, None, [], Lam(Tup(x: Var(B)), Bra(rcd = false, Asc(Var(x), TypeName(B)))))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit()), NuFunDef(None, foo, N, Nil, L(Lam(Tup((S(Var("x")), Var("B"))), Bra(rcd = false, Asc(Var("x"), TypeName(B))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1,]) {} @@ -41,7 +41,7 @@ fun foo = //│ |#fun| |foo| |#=|→|#let| |local|(|x|)| |#=|→|#class| |Foo| |{|→|#fun| |bar| |#=| |x| |+| |1|←|↵|}|↵|Foo|(||)|.bar|←|↵|print| |#of| |local|(|0|)| |+| |local|(|1|)|↵|print| |#of| |(|local| |#of| |0|)| |+| |local| |#of| |1|↵|#fun| |tmp| |#=| |1|↵|print| |#of| |local| |#of| |0| |+| |local| |#of| |1|↵|#fun| |tmp| |#=| |2|←| //│ Parsed: {fun foo = {let local = (x,) => {class Foo {fun bar = +(x, 1,)}; (Foo()).bar}; print(+(local(0,), local(1,),),); print(+('(' local(0,) ')', local(1,),),); fun tmp = 1; print(local(+(0, local(1,),),),); fun tmp = 2}} //│ Parsed: -//│ TypingUnit(NuFunDef(None, foo, None, [], Blk(...))) +//│ TypingUnit(NuFunDef(None, foo, N, Nil, L(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, IntLit(1)))))))), Sel(App(Var("Foo"), Tup()), bar))))), App(Var("print"), Tup((N, App(Var("+"), Tup((N, App(Var("local"), Tup((N, IntLit(0))))), (N, App(Var("local"), Tup((N, IntLit(1)))))))))), App(Var("print"), Tup((N, App(Var("+"), Tup((N, Bra(rcd = false, App(Var("local"), Tup((N, IntLit(0)))))), (N, App(Var("local"), Tup((N, IntLit(1)))))))))), NuFunDef(None, tmp, N, Nil, L(IntLit(1))), App(Var("print"), Tup((N, App(Var("local"), Tup((N, App(Var("+"), Tup((N, IntLit(0)), (N, App(Var("local"), Tup((N, IntLit(1))))))))))))), NuFunDef(None, tmp, N, Nil, L(IntLit(2))))))) //│ Lifted: //│ TypingUnit { //│ class Foo$1([x,]) {fun bar = () => +((this).x, 1,)} @@ -57,7 +57,7 @@ f(0) //│ |#class| |A|(|y|)|{||}|↵|#let| |f| |#=| |x| |#=>| |#new| |A|(|0|)|{|#fun| |bar| |#=| |x|+|y|}|↵|f|(|0|)| //│ Parsed: {class A(y,) {}; let f = (x,) => (new A)(0,) { ‹fun bar = +(x, y,)› }; f(0,)} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, A, (), Tup(_: Var(y)), (), None, None, TypingUnit()), NuFunDef(Some(false), f, None, [], Lam(Tup(_: Var(x)), Rft(App(NuNew(Var(A)), Tup(_: IntLit(0))), ...))), App(Var(f), Tup(_: IntLit(0)))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("y")))), N, N, Ls(), N, N, TypingUnit()), NuFunDef(Some(false), f, N, Nil, L(Lam(Tup((N, Var("x"))), Rft(App(NuNew(Var("A")), Tup((N, IntLit(0)))), TypingUnit(NuFunDef(None, bar, N, Nil, L(App(Var("+"), Tup((N, Var("x")), (N, Var("y"))))))))))), App(Var("f"), Tup((N, IntLit(0))))) //│ Lifted: //│ TypingUnit { //│ class A$1([y,]) {} @@ -80,7 +80,7 @@ class A(x){ //│ |#class| |A|(|x|)|{|→|#fun| |w| |#=| |x|↵|#fun| |foo|(|y|)| |#=| |→|#class| |B|(|z|)|{|→|#fun| |bar| |#=| |x|+|y|+|z|←|↵|}|↵|#new| |B|(|0|)|{|→|#fun| |bar| |#=| |w|+|y|+|z|←|↵|}|←|←|↵|}| //│ Parsed: {class A(x,) {fun w = x; fun foo = (y,) => {class B(z,) {fun bar = +(+(x, y,), z,)}; (new B)(0,) { ‹fun bar = +(+(w, y,), z,)› }}}} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, A, (), Tup(_: Var(x)), (), None, None, TypingUnit(NuFunDef(None, w, None, [], Var(x)), NuFunDef(None, foo, None, [], Lam(Tup(_: Var(y)), Blk(...)))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, w, N, Nil, L(Var("x"))), NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("y"))), Blk(NuTypeDef(Cls, TypeName("B"), Ls(), S(Tup((N, Var("z")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(App(Var("+"), Tup((N, App(Var("+"), Tup((N, Var("x")), (N, Var("y"))))), (N, Var("z")))))))), Rft(App(NuNew(Var("B")), Tup((N, IntLit(0)))), TypingUnit(NuFunDef(None, bar, N, Nil, L(App(Var("+"), Tup((N, App(Var("+"), Tup((N, Var("w")), (N, Var("y"))))), (N, Var("z"))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1, z, y,]) { @@ -111,7 +111,7 @@ fun f(x,y,z) = //│ |#fun| |f|(|x|,|y|,|z|)| |#=| |→|#class| |A|{|→|#fun| |foo| |#=| |#new| |B|↵|#fun| |bar1| |#=| |x|←|↵|}|↵|#class| |B|{|→|#fun| |foo| |#=| |#new| |A|↵|#fun| |bar2| |#=| |y|←|↵|}|↵|#class| |C| |#extends| |A|,| |B| |{|→|#fun| |bar| |#=| |bar1| |+| |bar2|←|↵|}|←| //│ Parsed: {fun f = (x, y, z,) => {class A {fun foo = new B; fun bar1 = x}; class B {fun foo = new A; fun bar2 = y}; class C: A, B {fun bar = +(bar1, bar2,)}}} //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, None, [], Lam(Tup(_: Var(x), _: Var(y), _: Var(z)), Blk(...)))) +//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x")), (N, Var("y")), (N, Var("z"))), Blk(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(NuNew(Var("B")))), NuFunDef(None, bar1, N, Nil, L(Var("x"))))), NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(NuNew(Var("A")))), NuFunDef(None, bar2, N, Nil, L(Var("y"))))), NuTypeDef(Cls, TypeName("C"), Ls(), N, N, N, Ls(Var("A"), Var("B")), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(App(Var("+"), Tup((N, Var("bar1")), (N, Var("bar2"))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1([x, y,]) { @@ -142,7 +142,7 @@ fun f(x,y,z) = //│ |#fun| |f|(|x|,|y|,|z|)| |#=| |→|#class| |C|{|→|#class| |A|{|→|#fun| |foo| |#=| |#new| |B|↵|#fun| |bar1| |#=| |x|←|↵|}|↵|#class| |B|{|→|#fun| |foo| |#=| |#new| |A|↵|#fun| |bar2| |#=| |y|←|↵|}|↵|#fun| |boo| |#=| |(|#new| |A|)|.bar1| |+| |B|(||)|.bar2| |+| |z|←|↵|}|←| //│ Parsed: {fun f = (x, y, z,) => {class C {class A {fun foo = new B; fun bar1 = x}; class B {fun foo = new A; fun bar2 = y}; fun boo = +(+(('(' new A ')').bar1, (B()).bar2,), z,)}}} //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, None, [], Lam(Tup(_: Var(x), _: Var(y), _: Var(z)), Blk(...)))) +//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x")), (N, Var("y")), (N, Var("z"))), Blk(NuTypeDef(Cls, TypeName("C"), 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(NuNew(Var("B")))), NuFunDef(None, bar1, N, Nil, L(Var("x"))))), NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(NuNew(Var("A")))), NuFunDef(None, bar2, N, Nil, L(Var("y"))))), NuFunDef(None, boo, N, Nil, L(App(Var("+"), Tup((N, App(Var("+"), Tup((N, Sel(Bra(rcd = false, NuNew(Var("A"))), bar1)), (N, Sel(App(Var("B"), Tup()), bar2))))), (N, Var("z"))))))))))))) //│ Lifted: //│ TypingUnit { //│ class C$1_A$2([par$C$1,]) { @@ -168,7 +168,7 @@ fun f(y) = //│ |#fun| |f|(|y|)| |#=|→|#let| |g|(|x|)| |#=| |x| |+| |y| |+| |1|↵|#class| |Foo|(|x|)| |{|→|#fun| |h| |#=| |g|(|x|)|←|↵|}|←| //│ Parsed: {fun f = (y,) => {let g = (x,) => +(+(x, y,), 1,); class Foo(x,) {fun h = g(x,)}}} //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, None, [], Lam(Tup(_: Var(y)), Blk(...)))) +//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("y"))), Blk(NuFunDef(Some(false), g, N, Nil, L(Lam(Tup((N, Var("x"))), App(Var("+"), Tup((N, App(Var("+"), Tup((N, Var("x")), (N, Var("y"))))), (N, IntLit(1))))))), NuTypeDef(Cls, TypeName("Foo"), Ls(), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, h, N, Nil, L(App(Var("g"), Tup((N, Var("x"))))))))))))) //│ Lifted: //│ TypingUnit { //│ class Foo$1([x, y,]) {fun h = () => g$2((this).x, y,)} @@ -180,7 +180,7 @@ fun f(y) = //│ | |Foo|(|1|)|.h| //│ Parsed: {(Foo(1,)).h} //│ Parsed: -//│ TypingUnit(Sel(App(Var(Foo), Tup(_: IntLit(1))), h)) +//│ TypingUnit(Sel(App(Var("Foo"), Tup((N, IntLit(1)))), h)) //│ Lifted: //│ TypingUnit {Code(List((Foo(1,)).h))} //│ @@ -188,7 +188,7 @@ fun f(y) = //│ | |Foo|(|x|)|.h| //│ Parsed: {(Foo(x,)).h} //│ Parsed: -//│ TypingUnit(Sel(App(Var(Foo), Tup(_: Var(x))), h)) +//│ TypingUnit(Sel(App(Var("Foo"), Tup((N, Var("x")))), h)) //│ Lifted: //│ TypingUnit {Code(List((Foo(x,)).h))} //│ @@ -204,7 +204,7 @@ fun f(x) = //│ |#fun| |f|(|x|)| |#=|→|#let| |g|(|x|)| |#=| |→|#let| |h|(|x|)| |#=| |x| |+| |2|↵|Foo|(|h|(|x|)|,| |x|)|.bar|←|↵|#class| |Foo|(|x|,| |y|)| |{|→|#fun| |bar| |#=| |g|(|x|)|+|y|←|↵|}|↵|Foo|(|x|,| |x|)|.bar|←| //│ Parsed: {fun f = (x,) => {let g = (x,) => {let h = (x,) => +(x, 2,); (Foo(h(x,), x,)).bar}; class Foo(x, y,) {fun bar = +(g(x,), y,)}; (Foo(x, x,)).bar}} //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, None, [], Lam(Tup(_: Var(x)), Blk(...)))) +//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(NuFunDef(Some(false), g, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(NuFunDef(Some(false), h, N, Nil, L(Lam(Tup((N, Var("x"))), App(Var("+"), Tup((N, Var("x")), (N, IntLit(2))))))), Sel(App(Var("Foo"), Tup((N, App(Var("h"), Tup((N, Var("x"))))), (N, Var("x")))), bar))))), NuTypeDef(Cls, TypeName("Foo"), Ls(), S(Tup((N, Var("x")), (N, Var("y")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(App(Var("+"), Tup((N, App(Var("g"), Tup((N, Var("x"))))), (N, Var("y")))))))), Sel(App(Var("Foo"), Tup((N, Var("x")), (N, Var("x")))), bar)))))) //│ Lifted: //│ TypingUnit { //│ class Foo$1([x, y,]) {fun bar = () => +(g$2((this).x,), (this).y,)} @@ -218,7 +218,7 @@ class Foo(x, y) extends Bar(y, x), Baz(x + y) //│ |#class| |Foo|(|x|,| |y|)| |#extends| |Bar|(|y|,| |x|)|,| |Baz|(|x| |+| |y|)| //│ Parsed: {class Foo(x, y,): Bar(y, x,), Baz(+(x, y,),) {}} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, Foo, (), Tup(_: Var(x), _: Var(y)), (App(Var(Bar), Tup(_: Var(y), _: Var(x))), App(Var(Baz), Tup(_: App(Var(+), Tup(_: Var(x), _: Var(y)))))), None, None, TypingUnit())) +//│ TypingUnit(NuTypeDef(Cls, TypeName("Foo"), Ls(), S(Tup((N, Var("x")), (N, Var("y")))), N, N, Ls(App(Var("Bar"), Tup((N, Var("y")), (N, Var("x")))), App(Var("Baz"), Tup((N, App(Var("+"), Tup((N, Var("x")), (N, Var("y")))))))), N, N, TypingUnit())) //│ Lifted: //│ TypingUnit { //│ class Foo$1([x, y,]): Bar((this).y, (this).x,), Baz(+((this).x, (this).y,),) {} @@ -233,7 +233,7 @@ fun foo(x: T): string = //│ |#fun| |foo|‹|T|,| |U|›|(|x|#:| |T|)|#:| |string| |#=| |→|#class| |A|(|y|)| |#extends| |B|‹|T|›|,| |C|(|y|#:| |U|)| |{|→|#fun| |bar| |#=| |this|←|↵|}|↵|"rua"|←| //│ Parsed: {fun foo = (x: T,) => {class A(y,): B‹T›, C(y: U,) {fun bar = this}; "rua"} : string} //│ Parsed: -//│ TypingUnit(NuFunDef(None, foo, None, [TypeName(T), TypeName(U)], Lam(Tup(x: Var(T)), Asc(Blk(...), TypeName(string))))) +//│ TypingUnit(NuFunDef(None, foo, N, TypeName("T") :: TypeName("U") :: Nil, L(Lam(Tup((S(Var("x")), Var("T"))), Asc(Blk(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("y")))), N, N, Ls(TyApp(Var("B"), List(TypeName(T))), App(Var("C"), Tup((S(Var("y")), Var("U"))))), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(Var("this"))))), StrLit(rua)), TypeName(string)))))) //│ Lifted: //│ TypingUnit { //│ class A$1[T,U]([y,]): B‹T›, C(y: U,) {fun bar = () => this} @@ -250,7 +250,7 @@ class A{ //│ |#class| |A|‹|T|›|{|→|#class| |B|{|→|#fun| |f| |#=| |x| |#=>| |y| |#=>| |x|↵|#fun| |g|#:| |T| |#=>| |B| |#=>| |T|←|↵|}|←|↵|}| //│ Parsed: {class A‹T› {class B {fun f = (x,) => (y,) => x; fun g: T -> B -> T}}} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, A, ((None,TypeName(T))), Tup(), (), None, None, TypingUnit(NuTypeDef(class, B, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, f, None, [], Lam(Tup(_: Var(x)), Lam(Tup(_: Var(y)), Var(x)))), NuFunDef(None, g, None, [], PolyType(List(),Function(Tuple(List((None,Field(None,TypeName(T))))),Function(Tuple(List((None,Field(None,TypeName(B))))),TypeName(T)))))))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(N -> TypeName("T")), N, N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x"))), Lam(Tup((N, Var("y"))), Var("x"))))), NuFunDef(None, g, N, Nil, R(PolyType(Ls(), Function(Tuple(N -> Fld(N, TypeName("T"))), Function(Tuple(N -> Fld(N, TypeName("B"))), TypeName("T"))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2_Lambda1$1$3([par$A$1_B$2, x,]) {fun apply = (y,) => (this).x} @@ -270,7 +270,7 @@ class Foo{ //│ |#class| |Foo|‹|T|›|{|→|#class| |RectangleBox|#:| |Box|‹|T|›| |&| |{| |breadth|#:| |T| |}|↵|#class| |StackedRectangleBoxes|‹|N|›| |#:| |RectangleBox|‹|T|›| |&| |{| |size|#:| |N| |}|↵|#class| |Bar|#:| |{|any|#:| |RectangleBox| |#=>| |StackedRectangleBoxes|}|←|↵|}| //│ Parsed: {class Foo‹T› {class RectangleBox: Box[T] & {breadth: T} {}; class StackedRectangleBoxes‹N›: RectangleBox[T] & {size: N} {}; class Bar: {any: RectangleBox -> StackedRectangleBoxes} {}}} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, Foo, ((None,TypeName(T))), Tup(), (), None, None, TypingUnit(NuTypeDef(class, RectangleBox, (), Tup(), (), None, None, TypingUnit()), NuTypeDef(class, StackedRectangleBoxes, ((None,TypeName(N))), Tup(), (), None, None, TypingUnit()), NuTypeDef(class, Bar, (), Tup(), (), None, None, TypingUnit())))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("Foo"), Ls(N -> TypeName("T")), N, N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("RectangleBox"), Ls(), N, N, S(Inter(AppliedType(TypeName("Box"), TypeName("T") :: Nil), Record(breadth: Fld(N, TypeName("T"))))), Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("StackedRectangleBoxes"), Ls(N -> TypeName("N")), N, N, S(Inter(AppliedType(TypeName("RectangleBox"), TypeName("T") :: Nil), Record(size: Fld(N, TypeName("N"))))), Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("Bar"), Ls(), N, N, S(Record(any: Fld(N, Function(Tuple(N -> Fld(N, TypeName("RectangleBox"))), TypeName("StackedRectangleBoxes"))))), Ls(), N, N, TypingUnit())))) //│ Lifted: //│ TypingUnit { //│ class Foo$1_RectangleBox$2([par$Foo$1,]) {} @@ -293,7 +293,7 @@ fun ctx(a,b) = //│ |#class| |Func|‹|T|,| |U|›| |{|→|#fun| |apply|#:| |T| |#=>| |U|←|↵|}|↵|#class| |Lambda|‹|T|,| |U|›| |#:| |Func|‹|T|,| |U|›| |{||}|↵|#fun| |ctx|(|a|,|b|)| |#=|→|#fun| |foo|(|f|#:| |Func|,| |x|)| |#=| |→|f|.apply|(|x|)|←|↵|foo|(|#new| |Lambda|{|→|#fun| |apply|(|x|)| |#=| |a|+|x|←|↵|}|,| |b|)|←| //│ Parsed: {class Func‹T, U› {fun apply: T -> U}; class Lambda‹T, U›: Func[T, U] {}; fun ctx = (a, b,) => {fun foo = (f: Func, x,) => {(f).apply(x,)}; foo(new Lambda { ‹fun apply = (x,) => +(a, x,)› }, b,)}} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, Func, ((None,TypeName(T)), (None,TypeName(U))), Tup(), (), None, None, TypingUnit(NuFunDef(None, apply, None, [], PolyType(List(),Function(Tuple(List((None,Field(None,TypeName(T))))),TypeName(U)))))), NuTypeDef(class, Lambda, ((None,TypeName(T)), (None,TypeName(U))), Tup(), (), None, None, TypingUnit()), NuFunDef(None, ctx, None, [], Lam(Tup(_: Var(a), _: Var(b)), Blk(...)))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("Func"), Ls(N -> TypeName("T"), N -> TypeName("U")), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, apply, N, Nil, R(PolyType(Ls(), Function(Tuple(N -> Fld(N, TypeName("T"))), TypeName("U"))))))), NuTypeDef(Cls, TypeName("Lambda"), Ls(N -> TypeName("T"), N -> TypeName("U")), N, N, S(AppliedType(TypeName("Func"), TypeName("T") :: TypeName("U") :: Nil)), Ls(), N, N, TypingUnit()), NuFunDef(None, ctx, N, Nil, L(Lam(Tup((N, Var("a")), (N, Var("b"))), Blk(NuFunDef(None, foo, N, Nil, L(Lam(Tup((S(Var("f")), Var("Func")), (N, Var("x"))), Blk(App(Sel(Var("f"), apply), Tup((N, Var("x")))))))), App(Var("foo"), Tup((N, Rft(NuNew(Var("Lambda")), TypingUnit(NuFunDef(None, apply, N, Nil, L(Lam(Tup((N, Var("x"))), App(Var("+"), Tup((N, Var("a")), (N, Var("x")))))))))), (N, Var("b"))))))))) //│ Lifted: //│ TypingUnit { //│ class Func$1[T,U]([]) {fun apply = T -> U} @@ -309,7 +309,7 @@ f(MyClass) //│ |#fun| |f|(|T|)| |#=| |→|#new| |T|(||)|←|↵|f|(|MyClass|)| //│ Parsed: {fun f = (T,) => {(new T)()}; f(MyClass,)} //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, None, [], Lam(Tup(_: Var(T)), Blk(...))), App(Var(f), Tup(_: Var(MyClass)))) +//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("T"))), Blk(App(NuNew(Var("T")), Tup()))))), App(Var("f"), Tup((N, Var("MyClass"))))) //│ Lifted: //│ Lifting failed: mlscript.codegen.CodeGenError: Cannot find type T. Class values are not supported in lifter. //│ @@ -322,7 +322,7 @@ class A { //│ |#class| |A| |{|→|#fun| |foo| |#=| |→|#fun| |bar| |#=| |foo|(||)|↵|bar|(||)|←|←|↵|}| //│ Parsed: {class A {fun foo = {fun bar = foo(); bar()}}} //│ Parsed: -//│ TypingUnit(NuTypeDef(class, A, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, foo, None, [], Blk(...))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Blk(NuFunDef(None, bar, N, Nil, L(App(Var("foo"), Tup()))), App(Var("bar"), Tup()))))))) //│ Lifted: //│ TypingUnit { //│ class A$1([]) {fun foo = () => {bar$1(this,)}} diff --git a/compiler/shared/test/diff/mono.mls b/compiler/shared/test/diff/mono.mls index 780851b8a..31ec3e212 100644 --- a/compiler/shared/test/diff/mono.mls +++ b/compiler/shared/test/diff/mono.mls @@ -4,7 +4,7 @@ :mono fun f(x: Int) = if x then 42 else 1337 //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, None, [], Lam(Tup(x: Var(Int)), If(IfThen(Var(x), IntLit(42), Some(IntLit(1337)))))) +//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((S(Var("x")), Var("Int"))), If(IfThen(Var("x"), IntLit(42), Some(IntLit(1337))))))) //│ Lifted: //│ TypingUnit { //│ fun f$1 = (x: Int,) => if (x) then 42 else 1337 @@ -19,7 +19,7 @@ fun f(x: Int) = if x then 42 else 1337 :mono fun foo() = 42 //│ Parsed: -//│ TypingUnit(NuFunDef(None, foo, None, [], Lam(Tup(), IntLit(42)))) +//│ TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup(), IntLit(42))))) //│ Lifted: //│ TypingUnit {fun foo$1 = () => 42} //│ Mono: @@ -34,7 +34,7 @@ fun foo(x, #b) = if b then x else 1337 let a = foo(42, true) let b = foo(23, false) //│ Parsed: -//│ TypingUnit(NuFunDef(None, foo, None, [], Lam(Tup(_: Var(x), _: Var(b)), If(IfThen(Var(b), Var(x), Some(IntLit(1337))))), NuFunDef(Some(false), a, None, [], App(Var(foo), Tup(_: IntLit(42), _: Var(true)))), NuFunDef(Some(false), b, None, [], App(Var(foo), Tup(_: IntLit(23), _: Var(false))))) +//│ TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("x")), (N, Var("b"))), If(IfThen(Var("b"), Var("x"), Some(IntLit(1337)))))), NuFunDef(Some(false), a, N, Nil, L(App(Var("foo"), Tup((N, IntLit(42)), (N, Var("true")))))), NuFunDef(Some(false), b, N, Nil, L(App(Var("foo"), Tup((N, IntLit(23)), (N, Var("false"))))))) //│ Lifted: //│ TypingUnit { //│ fun foo$3 = (x, #b,) => if (b) then x else 1337 @@ -61,7 +61,7 @@ let b = foo(23, false) :mono let x = 42 + 1337 //│ Parsed: -//│ TypingUnit(NuFunDef(Some(false), x, None, [], App(Var(+), Tup(_: IntLit(42), _: IntLit(1337))))) +//│ TypingUnit(NuFunDef(Some(false), x, N, Nil, L(App(Var("+"), Tup((N, IntLit(42)), (N, IntLit(1337))))))) //│ Lifted: //│ TypingUnit {let x$1 = () => +(42, 1337,)} //│ Mono: @@ -99,7 +99,7 @@ let x = 42 + 1337 if true then 1 else 0 if 1+1 > 1 then 1 - 1 else 1*1 //│ Parsed: -//│ TypingUnit(If(IfThen(Var(true), IntLit(1), Some(IntLit(0))), If(IfThen(App(Var(>), Tup(_: App(Var(+), Tup(_: IntLit(1), _: IntLit(1))), _: IntLit(1))), App(Var(-), Tup(_: IntLit(1), _: IntLit(1))), Some(App(Var(*), Tup(_: IntLit(1), _: IntLit(1)))))) +//│ TypingUnit(If(IfThen(Var("true"), IntLit(1), Some(IntLit(0))), If(IfThen(App(Var(">"), Tup((N, App(Var("+"), Tup((N, IntLit(1)), (N, IntLit(1))))), (N, IntLit(1)))), App(Var("-"), Tup((N, IntLit(1)), (N, IntLit(1)))), Some(App(Var("*"), Tup((N, IntLit(1)), (N, IntLit(1))))))) //│ Lifted: //│ TypingUnit { //│ Code(List(if (true) then 1 else 0)) @@ -123,7 +123,7 @@ if 1+1 > 1 then 1 - 1 else 1*1 :mono if(b) then 1 else 2 //│ Parsed: -//│ TypingUnit(If(IfThen(Bra(rcd = false, Var(b)), IntLit(1), Some(IntLit(2)))) +//│ TypingUnit(If(IfThen(Bra(rcd = false, Var("b")), IntLit(1), Some(IntLit(2)))) //│ Lifted: //│ TypingUnit {Code(List(if ('(' b ')') then 1 else 2))} //│ Mono: @@ -139,7 +139,7 @@ if(b) then 1 else 2 :mono ((f, g) => f(g))(f => f, true) //│ Parsed: -//│ TypingUnit(App(Bra(rcd = false, Lam(Tup(_: Var(f), _: Var(g)), App(Var(f), Tup(_: Var(g))))), Tup(_: Lam(Tup(_: Var(f)), Var(f)), _: Var(true)))) +//│ TypingUnit(App(Bra(rcd = false, Lam(Tup((N, Var("f")), (N, Var("g"))), App(Var("f"), Tup((N, Var("g")))))), Tup((N, Lam(Tup((N, Var("f"))), Var("f"))), (N, Var("true"))))) //│ Lifted: //│ TypingUnit { //│ class Lambda2$1$1([]) {fun apply = (f, g,) => f(g,)} @@ -168,7 +168,7 @@ if(b) then 1 else 2 :mono (b => if b then true else false) (true) //│ Parsed: -//│ TypingUnit(App(Bra(rcd = false, Lam(Tup(_: Var(b)), If(IfThen(Var(b), Var(true), Some(Var(false))))), Tup(_: Var(true)))) +//│ TypingUnit(App(Bra(rcd = false, Lam(Tup((N, Var("b"))), If(IfThen(Var("b"), Var("true"), Some(Var("false"))))), Tup((N, Var("true"))))) //│ Lifted: //│ TypingUnit { //│ class Lambda1$1$1([]) {fun apply = (b,) => if (b) then true else false} @@ -193,7 +193,7 @@ fun f(x) = if(x > 0) then x+1 else x - 1 f(2)+3 //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, None, [], Lam(Tup(_: Var(x)), Blk(...))), App(Var(+), Tup(_: App(Var(f), Tup(_: IntLit(2))), _: IntLit(3)))) +//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(If(IfThen(Bra(rcd = false, App(Var(">"), Tup((N, Var("x")), (N, IntLit(0))))), App(Var("+"), Tup((N, Var("x")), (N, IntLit(1)))), Some(App(Var("-"), Tup((N, Var("x")), (N, IntLit(1)))))))))), App(Var("+"), Tup((N, App(Var("f"), Tup((N, IntLit(2))))), (N, IntLit(3))))) //│ Lifted: //│ TypingUnit { //│ fun f$1 = (x,) => {if ('(' >(x, 0,) ')') then +(x, 1,) else -(x, 1,)} @@ -217,7 +217,7 @@ fun fac(n) = if (n > 1) then fac(n - 1) * n else 1 fac(2) //│ Parsed: -//│ TypingUnit(NuFunDef(None, fac, None, [], Lam(Tup(_: Var(n)), Blk(...))), App(Var(fac), Tup(_: IntLit(2)))) +//│ TypingUnit(NuFunDef(None, fac, N, Nil, L(Lam(Tup((N, Var("n"))), Blk(If(IfThen(Bra(rcd = false, App(Var(">"), Tup((N, Var("n")), (N, IntLit(1))))), App(Var("*"), Tup((N, App(Var("fac"), Tup((N, App(Var("-"), Tup((N, Var("n")), (N, IntLit(1)))))))), (N, Var("n")))), Some(IntLit(1))))))), App(Var("fac"), Tup((N, IntLit(2))))) //│ Lifted: //│ TypingUnit { //│ fun fac$1 = (n,) => {if ('(' >(n, 1,) ')') then *(fac$1(-(n, 1,),), n,) else 1} @@ -246,7 +246,7 @@ fun count(lst) = else 0 count(new List(new List(new Nil(undefined, false), true), true)) //│ Parsed: -//│ TypingUnit(NuTypeDef(class, List, (), Tup(l: App(Var(|), Tup(_: App(Var(|), Tup(_: Var(List), _: Var(Nil))), _: UnitLit(true))), hasTail: Var(Bool)), (), None, None, TypingUnit()), NuTypeDef(class, Nil, (), Tup(l: App(Var(|), Tup(_: App(Var(|), Tup(_: Var(List), _: Var(Nil))), _: UnitLit(true))), hasTail: Var(Bool)), (), None, None, TypingUnit()), NuFunDef(None, count, None, [], Lam(Tup(_: Var(lst)), Blk(...))), App(Var(count), Tup(_: App(NuNew(Var(List)), Tup(_: App(NuNew(Var(List)), Tup(_: App(NuNew(Var(Nil)), Tup(_: UnitLit(true), _: Var(false))), _: Var(true))), _: Var(true)))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("List"), Ls(), S(Tup((S(Var("l")), App(Var("|"), Tup((N, App(Var("|"), Tup((N, Var("List")), (N, Var("Nil"))))), (N, UnitLit(true))))), (S(Var("hasTail")), Var("Bool")))), N, N, Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("Nil"), Ls(), S(Tup((S(Var("l")), App(Var("|"), Tup((N, App(Var("|"), Tup((N, Var("List")), (N, Var("Nil"))))), (N, UnitLit(true))))), (S(Var("hasTail")), Var("Bool")))), N, N, Ls(), N, N, TypingUnit()), NuFunDef(None, count, N, Nil, L(Lam(Tup((N, Var("lst"))), Blk(If(IfThen(Sel(Var("lst"), hasTail), Blk(NuFunDef(Some(false), l, N, Nil, L(Sel(Var("lst"), l))), If(IfThen(App(Var("is"), Tup((N, Var("l")), (N, UnitLit(true)))), IntLit(1), Some(App(Var("+"), Tup((N, App(Var("count"), Tup((N, Var("l"))))), (N, IntLit(1))))))), Some(IntLit(0))))))), App(Var("count"), Tup((N, App(NuNew(Var("List")), Tup((N, App(NuNew(Var("List")), Tup((N, App(NuNew(Var("Nil")), Tup((N, UnitLit(true)), (N, Var("false"))))), (N, Var("true"))))), (N, Var("true")))))))) //│ Lifted: //│ TypingUnit { //│ class List$1([val l: |(|(List, Nil,), undefined,), val hasTail: Bool,]) {} @@ -303,7 +303,7 @@ class Nil() { fun add2(x) = x+2 (new List(1, new List(2, new Nil()))).map(x => x+1).map(x => add2(x)) //│ Parsed: -//│ TypingUnit(NuTypeDef(class, List, (), Tup(e: Var(Int), tail: App(Var(|), Tup(_: Var(List), _: Var(Nil)))), (), None, None, TypingUnit(NuFunDef(None, map, None, [], PolyType(List(),Function(Tuple(List((None,Field(None,Function(Tuple(List((None,Field(None,TypeName(Int))))),TypeName(Int)))))),TypeName(List)))), NuFunDef(None, map, None, [], Lam(Tup(_: Var(f)), App(NuNew(Var(List)), Tup(_: App(Var(f), Tup(_: Var(e))), _: App(Sel(Var(tail), map), Tup(_: Var(f))))))), NuFunDef(None, count, None, [], PolyType(List(),Function(Tuple(List()),TypeName(Int)))), NuFunDef(None, count, None, [], Lam(Tup(), App(Var(+), Tup(_: IntLit(1), _: App(Sel(Var(tail), count), Tup()))))))), NuTypeDef(class, Nil, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, map, None, [], Lam(Tup(_: Var(f)), Var(this))), NuFunDef(None, count, None, [], Lam(Tup(), IntLit(0))))), NuFunDef(None, add2, None, [], Lam(Tup(_: Var(x)), App(Var(+), Tup(_: Var(x), _: IntLit(2))))), App(Sel(App(Sel(Bra(rcd = false, App(NuNew(Var(List)), Tup(_: IntLit(1), _: App(NuNew(Var(List)), Tup(_: IntLit(2), _: App(NuNew(Var(Nil)), Tup())))))), map), Tup(_: Lam(Tup(_: Var(x)), App(Var(+), Tup(_: Var(x), _: IntLit(1)))))), map), Tup(_: Lam(Tup(_: Var(x)), App(Var(add2), Tup(_: Var(x))))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("List"), Ls(), S(Tup((S(Var("e")), Var("Int")), (S(Var("tail")), App(Var("|"), Tup((N, Var("List")), (N, Var("Nil"))))))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, map, N, Nil, R(PolyType(Ls(), Function(Tuple(N -> Fld(N, Function(Tuple(N -> Fld(N, TypeName("Int"))), TypeName("Int")))), TypeName("List"))))), NuFunDef(None, map, N, Nil, L(Lam(Tup((N, Var("f"))), App(NuNew(Var("List")), Tup((N, App(Var("f"), Tup((N, Var("e"))))), (N, App(Sel(Var("tail"), map), Tup((N, Var("f")))))))))), NuFunDef(None, count, N, Nil, R(PolyType(Ls(), Function(Tuple(), TypeName("Int"))))), NuFunDef(None, count, N, Nil, L(Lam(Tup(), App(Var("+"), Tup((N, IntLit(1)), (N, App(Sel(Var("tail"), count), Tup()))))))))), NuTypeDef(Cls, TypeName("Nil"), Ls(), S(Tup()), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, map, N, Nil, L(Lam(Tup((N, Var("f"))), Var("this")))), NuFunDef(None, count, N, Nil, L(Lam(Tup(), IntLit(0)))))), NuFunDef(None, add2, N, Nil, L(Lam(Tup((N, Var("x"))), App(Var("+"), Tup((N, Var("x")), (N, IntLit(2))))))), App(Sel(App(Sel(Bra(rcd = false, App(NuNew(Var("List")), Tup((N, IntLit(1)), (N, App(NuNew(Var("List")), Tup((N, IntLit(2)), (N, App(NuNew(Var("Nil")), Tup())))))))), map), Tup((N, Lam(Tup((N, Var("x"))), App(Var("+"), Tup((N, Var("x")), (N, IntLit(1)))))))), map), Tup((N, Lam(Tup((N, Var("x"))), App(Var("add2"), Tup((N, Var("x"))))))))) //│ Lifted: //│ TypingUnit { //│ class List$1([e: Int, tail: |(List, Nil,),]) { @@ -370,7 +370,7 @@ fun generate(x) = foo(new List(1, new List(2, new Nil()))) foo(generate(1)) //│ Parsed: -//│ TypingUnit(NuTypeDef(class, List, (), Tup(e: Var(Int), tail: App(Var(|), Tup(_: Var(List), _: Var(Nil)))), (), None, None, TypingUnit(NuFunDef(None, count, None, [], PolyType(List(),Function(Tuple(List()),TypeName(Int)))), NuFunDef(None, count, None, [], Lam(Tup(), App(Var(+), Tup(_: IntLit(1), _: App(Sel(Var(tail), count), Tup()))))))), NuTypeDef(class, Nil, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, count, None, [], Lam(Tup(), IntLit(0))))), NuFunDef(None, foo, None, [], Lam(Tup(_: Var(x)), App(Sel(Var(x), count), Tup()))), NuFunDef(None, generate, None, [], Lam(Tup(_: Var(x)), Blk(...))), App(Var(foo), Tup(_: App(NuNew(Var(List)), Tup(_: IntLit(1), _: App(NuNew(Var(List)), Tup(_: IntLit(2), _: App(NuNew(Var(Nil)), Tup()))))))), App(Var(foo), Tup(_: App(Var(generate), Tup(_: IntLit(1)))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("List"), Ls(), S(Tup((S(Var("e")), Var("Int")), (S(Var("tail")), App(Var("|"), Tup((N, Var("List")), (N, Var("Nil"))))))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, count, N, Nil, R(PolyType(Ls(), Function(Tuple(), TypeName("Int"))))), NuFunDef(None, count, N, Nil, L(Lam(Tup(), App(Var("+"), Tup((N, IntLit(1)), (N, App(Sel(Var("tail"), count), Tup()))))))))), NuTypeDef(Cls, TypeName("Nil"), Ls(), S(Tup()), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, count, N, Nil, L(Lam(Tup(), IntLit(0)))))), NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("x"))), App(Sel(Var("x"), count), Tup())))), NuFunDef(None, generate, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(If(IfThen(App(Var(">"), Tup((N, Var("x")), (N, IntLit(0)))), App(NuNew(Var("List")), Tup((N, Var("x")), (N, App(Var("generate"), Tup((N, App(Var("+"), Tup((N, Var("x")), (N, IntLit(1)))))))))), Some(App(NuNew(Var("Nil")), Tup()))))))), App(Var("foo"), Tup((N, App(NuNew(Var("List")), Tup((N, IntLit(1)), (N, App(NuNew(Var("List")), Tup((N, IntLit(2)), (N, App(NuNew(Var("Nil")), Tup())))))))))), App(Var("foo"), Tup((N, App(Var("generate"), Tup((N, IntLit(1)))))))) //│ Lifted: //│ TypingUnit { //│ class List$1([e: Int, tail: |(List, Nil,),]) { @@ -424,7 +424,7 @@ fun foo(x) = (f => f(x))(z => z+1) foo(2) //│ Parsed: -//│ TypingUnit(NuFunDef(None, foo, None, [], Lam(Tup(_: Var(x)), Blk(...))), App(Var(foo), Tup(_: IntLit(2)))) +//│ TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(App(Bra(rcd = false, Lam(Tup((N, Var("f"))), App(Var("f"), Tup((N, Var("x")))))), Tup((N, Lam(Tup((N, Var("z"))), App(Var("+"), Tup((N, Var("z")), (N, IntLit(1)))))))))))), App(Var("foo"), Tup((N, IntLit(2))))) //│ Lifted: //│ TypingUnit { //│ class Lambda1$2$1([x,]) {fun apply = (f,) => f((this).x,)} @@ -458,7 +458,7 @@ fun f(x) = (y => f(x+y))(x+1) f(1) //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, None, [], Lam(Tup(_: Var(x)), Blk(...))), App(Var(f), Tup(_: IntLit(1)))) +//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(App(Bra(rcd = false, Lam(Tup((N, Var("y"))), App(Var("f"), Tup((N, App(Var("+"), Tup((N, Var("x")), (N, Var("y"))))))))), Tup((N, App(Var("+"), Tup((N, Var("x")), (N, IntLit(1))))))))))), App(Var("f"), Tup((N, IntLit(1))))) //│ Lifted: //│ TypingUnit { //│ class Lambda1$2$1([x,]) {fun apply = (y,) => f$1(+((this).x, y,),)} @@ -489,7 +489,7 @@ fun f(x) = f(x) f(0) f(1) //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, None, [], Lam(Tup(_: Var(x)), App(Var(f), Tup(_: Var(x))))), App(Var(f), Tup(_: IntLit(0))), App(Var(f), Tup(_: IntLit(1)))) +//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x"))), App(Var("f"), Tup((N, Var("x"))))))), App(Var("f"), Tup((N, IntLit(0)))), App(Var("f"), Tup((N, IntLit(1))))) //│ Lifted: //│ TypingUnit { //│ fun f$1 = (x,) => f$1(x,) @@ -537,7 +537,7 @@ fun foo(x) = foo(new Lambda()) foo(new Lambda2(2)) //│ Parsed: -//│ TypingUnit(NuTypeDef(class, Cons, (), Tup(e: Var('A), tail: App(Var(|), Tup(_: Var(Cons), _: Var(Nil)))), (), None, None, TypingUnit(NuFunDef(None, count, None, [], PolyType(List(),Function(Tuple(List()),TypeName(Int)))), NuFunDef(None, count, None, [], Lam(Tup(), App(Var(+), Tup(_: IntLit(1), _: App(Sel(Var(tail), count), Tup()))))))), NuTypeDef(class, Nil, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, count, None, [], Lam(Tup(), IntLit(0))))), NuTypeDef(class, Lambda, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, apply, None, [], Lam(Tup(_: Var(l)), Blk(...))))), NuTypeDef(class, Lambda2, (), Tup(a: Var(Int)), (), None, None, TypingUnit(NuFunDef(None, apply, None, [], Lam(Tup(_: Var(l)), Blk(...))))), NuFunDef(None, foo, None, [], Lam(Tup(_: Var(x)), Blk(...))), App(Var(foo), Tup(_: App(NuNew(Var(Lambda)), Tup()))), App(Var(foo), Tup(_: App(NuNew(Var(Lambda2)), Tup(_: IntLit(2)))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("Cons"), Ls(), S(Tup((S(Var("e")), Var("'A")), (S(Var("tail")), App(Var("|"), Tup((N, Var("Cons")), (N, Var("Nil"))))))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, count, N, Nil, R(PolyType(Ls(), Function(Tuple(), TypeName("Int"))))), NuFunDef(None, count, N, Nil, L(Lam(Tup(), App(Var("+"), Tup((N, IntLit(1)), (N, App(Sel(Var("tail"), count), Tup()))))))))), NuTypeDef(Cls, TypeName("Nil"), Ls(), S(Tup()), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, count, N, Nil, L(Lam(Tup(), IntLit(0)))))), NuTypeDef(Cls, TypeName("Lambda"), Ls(), S(Tup()), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, apply, N, Nil, L(Lam(Tup((N, Var("l"))), Blk(App(Sel(Var("l"), count), Tup()))))))), NuTypeDef(Cls, TypeName("Lambda2"), Ls(), S(Tup((S(Var("a")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, apply, N, Nil, L(Lam(Tup((N, Var("l"))), Blk(App(Sel(Bra(rcd = false, App(NuNew(Var("Cons")), Tup((N, Var("a")), (N, Var("l"))))), count), Tup()))))))), NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(App(Var("+"), Tup((N, App(Sel(Var("x"), apply), Tup((N, App(NuNew(Var("Cons")), Tup((N, IntLit(1)), (N, App(NuNew(Var("Nil")), Tup())))))))), (N, App(Sel(Var("x"), apply), Tup((N, App(NuNew(Var("Nil")), Tup()))))))))))), App(Var("foo"), Tup((N, App(NuNew(Var("Lambda")), Tup())))), App(Var("foo"), Tup((N, App(NuNew(Var("Lambda2")), Tup((N, IntLit(2)))))))) //│ Lifted: //│ TypingUnit { //│ class Cons$1([e: 'A, tail: |(Cons, Nil,),]) { @@ -612,7 +612,7 @@ fun foo(x) = foo(l => l.count()) foo(l => (new Cons(2, l)).count()) //│ Parsed: -//│ TypingUnit(NuTypeDef(class, Cons, (), Tup(e: Var(Int), tail: App(Var(|), Tup(_: Var(Cons), _: Var(Nil)))), (), None, None, TypingUnit(NuFunDef(None, count, None, [], PolyType(List(),Function(Tuple(List()),TypeName(Int)))), NuFunDef(None, count, None, [], Lam(Tup(), App(Var(+), Tup(_: IntLit(1), _: App(Sel(Var(tail), count), Tup()))))))), NuTypeDef(class, Nil, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, count, None, [], Lam(Tup(), IntLit(0))))), NuFunDef(None, foo, None, [], Lam(Tup(_: Var(x)), Blk(...))), App(Var(foo), Tup(_: Lam(Tup(_: Var(l)), App(Sel(Var(l), count), Tup())))), App(Var(foo), Tup(_: Lam(Tup(_: Var(l)), App(Sel(Bra(rcd = false, App(NuNew(Var(Cons)), Tup(_: IntLit(2), _: Var(l)))), count), Tup()))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("Cons"), Ls(), S(Tup((S(Var("e")), Var("Int")), (S(Var("tail")), App(Var("|"), Tup((N, Var("Cons")), (N, Var("Nil"))))))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, count, N, Nil, R(PolyType(Ls(), Function(Tuple(), TypeName("Int"))))), NuFunDef(None, count, N, Nil, L(Lam(Tup(), App(Var("+"), Tup((N, IntLit(1)), (N, App(Sel(Var("tail"), count), Tup()))))))))), NuTypeDef(Cls, TypeName("Nil"), Ls(), S(Tup()), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, count, N, Nil, L(Lam(Tup(), IntLit(0)))))), NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(App(Var("+"), Tup((N, App(Var("x"), Tup((N, App(NuNew(Var("Cons")), Tup((N, IntLit(1)), (N, App(NuNew(Var("Nil")), Tup())))))))), (N, App(Var("x"), Tup((N, App(NuNew(Var("Nil")), Tup()))))))))))), App(Var("foo"), Tup((N, Lam(Tup((N, Var("l"))), App(Sel(Var("l"), count), Tup()))))), App(Var("foo"), Tup((N, Lam(Tup((N, Var("l"))), App(Sel(Bra(rcd = false, App(NuNew(Var("Cons")), Tup((N, IntLit(2)), (N, Var("l"))))), count), Tup())))))) //│ Lifted: //│ TypingUnit { //│ class Cons$1([e: Int, tail: |(Cons, Nil,),]) { @@ -707,7 +707,7 @@ class C(e1: Exp, e2: Exp) extends Exp { } (new C(new Ch(1), new A(new Ch(2), new Ch(3)))).derive(0).isEmpty() //│ Parsed: -//│ TypingUnit(NuTypeDef(class, Exp, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, derive, None, [], PolyType(List(),Function(Tuple(List((Some(x),Field(None,TypeName(Int))))),TypeName(Exp)))), NuFunDef(None, derive, None, [], Lam(Tup(x: Var(Int)), App(Var(Exp), Tup()))), NuFunDef(None, isEmpty, None, [], PolyType(List(),Function(Tuple(List()),TypeName(Bool)))), NuFunDef(None, isEmpty, None, [], Lam(Tup(), Var(false))))), NuTypeDef(class, E, (), Tup(), (Var(Exp)), None, None, TypingUnit(NuFunDef(None, derive, None, [], Lam(Tup(_: Var(x)), Blk(...))), NuFunDef(None, isEmpty, None, [], Lam(Tup(), Blk(...))))), NuTypeDef(class, Ep, (), Tup(), (Var(Exp)), None, None, TypingUnit(NuFunDef(None, derive, None, [], Lam(Tup(_: Var(x)), Blk(...))), NuFunDef(None, isEmpty, None, [], Lam(Tup(), Blk(...))))), NuTypeDef(class, Ch, (), Tup(i: Var(Int)), (Var(Exp)), None, None, TypingUnit(NuFunDef(None, derive, None, [], Lam(Tup(_: Var(x)), Blk(...))), NuFunDef(None, isEmpty, None, [], Lam(Tup(), Blk(...))))), NuTypeDef(class, A, (), Tup(e1: Var(Exp), e2: Var(Exp)), (Var(Exp)), None, None, TypingUnit(NuFunDef(None, derive, None, [], Lam(Tup(_: Var(x)), Blk(...))), NuFunDef(None, isEmpty, None, [], Lam(Tup(), Blk(...))))), NuTypeDef(class, C, (), Tup(e1: Var(Exp), e2: Var(Exp)), (Var(Exp)), None, None, TypingUnit(NuFunDef(None, derive, None, [], Lam(Tup(_: Var(x)), Blk(...))), NuFunDef(None, isEmpty, None, [], Lam(Tup(), Blk(...))))), App(Sel(App(Sel(Bra(rcd = false, App(NuNew(Var(C)), Tup(_: App(NuNew(Var(Ch)), Tup(_: IntLit(1))), _: App(NuNew(Var(A)), Tup(_: App(NuNew(Var(Ch)), Tup(_: IntLit(2))), _: App(NuNew(Var(Ch)), Tup(_: IntLit(3)))))))), derive), Tup(_: IntLit(0))), isEmpty), Tup())) +//│ TypingUnit(NuTypeDef(Cls, TypeName("Exp"), Ls(), S(Tup()), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, derive, N, Nil, R(PolyType(Ls(), Function(Tuple(S(x) -> Fld(N, TypeName("Int"))), TypeName("Exp"))))), NuFunDef(None, derive, N, Nil, L(Lam(Tup((S(Var("x")), Var("Int"))), App(Var("Exp"), Tup())))), NuFunDef(None, isEmpty, N, Nil, R(PolyType(Ls(), Function(Tuple(), TypeName("Bool"))))), NuFunDef(None, isEmpty, N, Nil, L(Lam(Tup(), Var("false")))))), NuTypeDef(Cls, TypeName("E"), Ls(), S(Tup()), N, N, Ls(Var("Exp")), N, N, TypingUnit(NuFunDef(None, derive, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(NuNew(Var("E")))))), NuFunDef(None, isEmpty, N, Nil, L(Lam(Tup(), Blk(Var("false"))))))), NuTypeDef(Cls, TypeName("Ep"), Ls(), S(Tup()), N, N, Ls(Var("Exp")), N, N, TypingUnit(NuFunDef(None, derive, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(NuNew(Var("E")))))), NuFunDef(None, isEmpty, N, Nil, L(Lam(Tup(), Blk(Var("true"))))))), NuTypeDef(Cls, TypeName("Ch"), Ls(), S(Tup((S(Var("i")), Var("Int")))), N, N, Ls(Var("Exp")), N, N, TypingUnit(NuFunDef(None, derive, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(If(IfThen(App(Var("=="), Tup((N, Var("x")), (N, Var("i")))), NuNew(Var("Ep")), Some(NuNew(Var("E")))))))), NuFunDef(None, isEmpty, N, Nil, L(Lam(Tup(), Blk(Var("false"))))))), NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((S(Var("e1")), Var("Exp")), (S(Var("e2")), Var("Exp")))), N, N, Ls(Var("Exp")), N, N, TypingUnit(NuFunDef(None, derive, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(App(NuNew(Var("A")), Tup((N, App(Sel(Var("e1"), derive), Tup((N, Var("x"))))), (N, App(Sel(Var("e2"), derive), Tup((N, Var("x"))))))))))), NuFunDef(None, isEmpty, N, Nil, L(Lam(Tup(), Blk(App(Var("||"), Tup((N, App(Sel(Var("e1"), isEmpty), Tup())), (N, App(Sel(Var("e2"), isEmpty), Tup())))))))))), NuTypeDef(Cls, TypeName("C"), Ls(), S(Tup((S(Var("e1")), Var("Exp")), (S(Var("e2")), Var("Exp")))), N, N, Ls(Var("Exp")), N, N, TypingUnit(NuFunDef(None, derive, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(If(IfThen(App(Sel(Var("e1"), isEmpty), Tup()), App(NuNew(Var("A")), Tup((N, App(NuNew(Var("C")), Tup((N, App(Sel(Var("e1"), derive), Tup((N, Var("x"))))), (N, Var("e2"))))), (N, App(Sel(Var("e2"), derive), Tup((N, Var("x"))))))), Some(App(NuNew(Var("C")), Tup((N, App(Sel(Var("e1"), derive), Tup((N, Var("x"))))), (N, Var("e2")))))))))), NuFunDef(None, isEmpty, N, Nil, L(Lam(Tup(), Blk(App(Var("&&"), Tup((N, App(Sel(Var("e1"), isEmpty), Tup())), (N, App(Sel(Var("e2"), isEmpty), Tup())))))))))), App(Sel(App(Sel(Bra(rcd = false, App(NuNew(Var("C")), Tup((N, App(NuNew(Var("Ch")), Tup((N, IntLit(1))))), (N, App(NuNew(Var("A")), Tup((N, App(NuNew(Var("Ch")), Tup((N, IntLit(2))))), (N, App(NuNew(Var("Ch")), Tup((N, IntLit(3))))))))))), derive), Tup((N, IntLit(0)))), isEmpty), Tup())) //│ Lifted: //│ TypingUnit { //│ class Exp$1([]) { @@ -809,7 +809,7 @@ fun gen() = if anyUnknown then new List(gen(), true) else new Nil(false) gen() //│ Parsed: -//│ TypingUnit(NuFunDef(Some(false), anyUnknown, None, [], Var(false)), NuTypeDef(class, List, (), Tup(l: App(Var(|), Tup(_: Var(List), _: Var(Nil))), hasTail: Var(Bool)), (), None, None, TypingUnit()), NuTypeDef(class, Nil, (), Tup(hasTail: Var(Bool)), (), None, None, TypingUnit()), NuFunDef(None, gen, None, [], Lam(Tup(), Blk(...))), App(Var(gen), Tup())) +//│ TypingUnit(NuFunDef(Some(false), anyUnknown, N, Nil, L(Var("false"))), NuTypeDef(Cls, TypeName("List"), Ls(), S(Tup((S(Var("l")), App(Var("|"), Tup((N, Var("List")), (N, Var("Nil"))))), (S(Var("hasTail")), Var("Bool")))), N, N, Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("Nil"), Ls(), S(Tup((S(Var("hasTail")), Var("Bool")))), N, N, Ls(), N, N, TypingUnit()), NuFunDef(None, gen, N, Nil, L(Lam(Tup(), Blk(If(IfThen(Var("anyUnknown"), App(NuNew(Var("List")), Tup((N, App(Var("gen"), Tup())), (N, Var("true")))), Some(App(NuNew(Var("Nil")), Tup((N, Var("false")))))))))), App(Var("gen"), Tup())) //│ Lifted: //│ TypingUnit { //│ class List$1([l: |(List, Nil,), hasTail: Bool,]) {} @@ -851,7 +851,7 @@ class Foo(x: Int){ } (new Foo(1)).boo(2) //│ Parsed: -//│ TypingUnit(NuTypeDef(class, Foo, (), Tup(x: Var(Int)), (), None, None, TypingUnit(NuFunDef(None, bar, None, [], Lam(Tup(_: Var(y)), App(Var(+), Tup(_: Var(x), _: Var(y))))), NuFunDef(None, boo, None, [], Lam(Tup(_: Var(z)), App(Var(+), Tup(_: App(Var(bar), Tup(_: Var(z))), _: Var(x))))))), App(Sel(Bra(rcd = false, App(NuNew(Var(Foo)), Tup(_: IntLit(1)))), boo), Tup(_: IntLit(2)))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("Foo"), Ls(), S(Tup((S(Var("x")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(Lam(Tup((N, Var("y"))), App(Var("+"), Tup((N, Var("x")), (N, Var("y"))))))), NuFunDef(None, boo, N, Nil, L(Lam(Tup((N, Var("z"))), App(Var("+"), Tup((N, App(Var("bar"), Tup((N, Var("z"))))), (N, Var("x"))))))))), App(Sel(Bra(rcd = false, App(NuNew(Var("Foo")), Tup((N, IntLit(1))))), boo), Tup((N, IntLit(2))))) //│ Lifted: //│ TypingUnit { //│ class Foo$1([x: Int,]) { @@ -888,7 +888,7 @@ class OneInt(a: Int){ } (new OneInt(10)).fac() //│ Parsed: -//│ TypingUnit(NuTypeDef(class, OneInt, (), Tup(a: Var(Int)), (), None, None, TypingUnit(NuFunDef(None, fac, None, [], PolyType(List(),Function(Tuple(List()),TypeName(Int)))), NuFunDef(None, fac, None, [], Lam(Tup(), Blk(...))))), App(Sel(Bra(rcd = false, App(NuNew(Var(OneInt)), Tup(_: IntLit(10)))), fac), Tup())) +//│ TypingUnit(NuTypeDef(Cls, TypeName("OneInt"), Ls(), S(Tup((S(Var("a")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, fac, N, Nil, R(PolyType(Ls(), Function(Tuple(), TypeName("Int"))))), NuFunDef(None, fac, N, Nil, L(Lam(Tup(), Blk(If(IfThen(Bra(rcd = false, App(Var(">"), Tup((N, Var("a")), (N, IntLit(0))))), App(Sel(Bra(rcd = false, App(NuNew(Var("OneInt")), Tup((N, App(Var("-"), Tup((N, Var("a")), (N, IntLit(1)))))))), fac), Tup()), Some(IntLit(1))))))))), App(Sel(Bra(rcd = false, App(NuNew(Var("OneInt")), Tup((N, IntLit(10))))), fac), Tup())) //│ Lifted: //│ TypingUnit { //│ class OneInt$1([a: Int,]) { @@ -938,7 +938,7 @@ fun g(x) = else f(x - 2) g(1) //│ Parsed: -//│ TypingUnit(NuFunDef(Some(false), any, None, [], IntLit(-20)), NuFunDef(None, f, None, [], Lam(Tup(_: Var(x)), Blk(...))), NuFunDef(None, g, None, [], Lam(Tup(_: Var(x)), Blk(...))), App(Var(g), Tup(_: IntLit(1)))) +//│ TypingUnit(NuFunDef(Some(false), any, N, Nil, L(IntLit(-20))), NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(If(IfThen(App(Var(">"), Tup((N, Var("x")), (N, Var("any")))), IntLit(0), Some(App(Var("g"), Tup((N, App(Var("-"), Tup((N, Var("x")), (N, IntLit(1))))))))))))), NuFunDef(None, g, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(If(IfThen(App(Var(">"), Tup((N, Var("x")), (N, Var("any")))), App(Var("g"), Tup((N, App(Var("-"), Tup((N, Var("x")), (N, IntLit(1))))))), Some(App(Var("f"), Tup((N, App(Var("-"), Tup((N, Var("x")), (N, IntLit(2))))))))))))), App(Var("g"), Tup((N, IntLit(1))))) //│ Lifted: //│ TypingUnit { //│ let any$3 = () => -20 @@ -977,7 +977,7 @@ class OneBool(b: Bool){ } (if b then new OneInt(1) else new OneBool(true)).get() //│ Parsed: -//│ TypingUnit(NuTypeDef(class, OneInt, (), Tup(a: Var(Int)), (), None, None, TypingUnit(NuFunDef(None, get, None, [], Lam(Tup(), Var(a))))), NuTypeDef(class, OneBool, (), Tup(b: Var(Bool)), (), None, None, TypingUnit(NuFunDef(None, get, None, [], Lam(Tup(), Var(b))))), App(Sel(Bra(rcd = false, If(IfThen(Var(b), App(NuNew(Var(OneInt)), Tup(_: IntLit(1))), Some(App(NuNew(Var(OneBool)), Tup(_: Var(true)))))), get), Tup())) +//│ TypingUnit(NuTypeDef(Cls, TypeName("OneInt"), Ls(), S(Tup((S(Var("a")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, get, N, Nil, L(Lam(Tup(), Var("a")))))), NuTypeDef(Cls, TypeName("OneBool"), Ls(), S(Tup((S(Var("b")), Var("Bool")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, get, N, Nil, L(Lam(Tup(), Var("b")))))), App(Sel(Bra(rcd = false, If(IfThen(Var("b"), App(NuNew(Var("OneInt")), Tup((N, IntLit(1)))), Some(App(NuNew(Var("OneBool")), Tup((N, Var("true"))))))), get), Tup())) //│ Lifted: //│ TypingUnit { //│ class OneInt$1([a: Int,]) {fun get = () => (this).a} @@ -1023,7 +1023,7 @@ baz(bar) (new Car()).da(Bar(1337)) bar.car //│ Parsed: -//│ TypingUnit(NuTypeDef(class, Bar, (), Tup(x: Var(Int)), (), None, None, TypingUnit(NuFunDef(None, foo, None, [], Lam(Tup(_: Var(x)), Var(x))), NuFunDef(None, FooMinus, None, [], Lam(Tup(y: Var(Int)), App(Var(+), Tup(_: Var(x), _: Var(y))))), NuFunDef(None, car, None, [], App(Var(foo), Tup(_: IntLit(2)))))), NuTypeDef(class, Car, (), Tup(), (), None, None, TypingUnit(NuFunDef(None, da, None, [], Lam(Tup(b: Var(Bar)), App(Sel(Var(b), foo), Tup(_: IntLit(2))))))), NuFunDef(None, baz, None, [], Lam(Tup(b: Var(Bar)), App(Sel(Var(b), foo), Tup(_: IntLit(2))))), NuFunDef(Some(false), bar, None, [], App(Var(Bar), Tup(_: IntLit(42)))), App(Var(baz), Tup(_: Var(bar))), App(Sel(Bra(rcd = false, App(NuNew(Var(Car)), Tup())), da), Tup(_: App(Var(Bar), Tup(_: IntLit(1337))))), Sel(Var(bar), car)) +//│ TypingUnit(NuTypeDef(Cls, TypeName("Bar"), Ls(), S(Tup((S(Var("x")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("x"))), Var("x")))), NuFunDef(None, FooMinus, N, Nil, L(Lam(Tup((S(Var("y")), Var("Int"))), App(Var("+"), Tup((N, Var("x")), (N, Var("y"))))))), NuFunDef(None, car, N, Nil, L(App(Var("foo"), Tup((N, IntLit(2)))))))), NuTypeDef(Cls, TypeName("Car"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, da, N, Nil, L(Lam(Tup((S(Var("b")), Var("Bar"))), App(Sel(Var("b"), foo), Tup((N, IntLit(2))))))))), NuFunDef(None, baz, N, Nil, L(Lam(Tup((S(Var("b")), Var("Bar"))), App(Sel(Var("b"), foo), Tup((N, IntLit(2))))))), NuFunDef(Some(false), bar, N, Nil, L(App(Var("Bar"), Tup((N, IntLit(42)))))), App(Var("baz"), Tup((N, Var("bar")))), App(Sel(Bra(rcd = false, App(NuNew(Var("Car")), Tup())), da), Tup((N, App(Var("Bar"), Tup((N, IntLit(1337))))))), Sel(Var("bar"), car)) //│ Lifted: //│ TypingUnit { //│ class Bar$1([x: Int,]) { @@ -1094,7 +1094,7 @@ class Sub2(c: Int) extends Sub(c+c){ (new Sub(10)).foo() (new Sub2(c)).foo() //│ Parsed: -//│ TypingUnit(NuFunDef(Some(false), c, None, [], IntLit(5)), NuTypeDef(class, Sup, (), Tup(a: Var(Int)), (), None, None, TypingUnit(NuFunDef(None, foo, None, [], Lam(Tup(), Var(a))))), NuTypeDef(class, Sub, (), Tup(b: Var(Int)), (App(Var(Sup), Tup(_: App(Var(+), Tup(_: Var(b), _: Var(b)))))), None, None, TypingUnit()), NuTypeDef(class, Sub2, (), Tup(c: Var(Int)), (App(Var(Sub), Tup(_: App(Var(+), Tup(_: Var(c), _: Var(c)))))), None, None, TypingUnit(NuFunDef(None, foo, None, [], Lam(Tup(), App(Var(+), Tup(_: Var(a), _: Var(c))))))), App(Sel(Bra(rcd = false, App(NuNew(Var(Sub)), Tup(_: IntLit(10)))), foo), Tup()), App(Sel(Bra(rcd = false, App(NuNew(Var(Sub2)), Tup(_: Var(c)))), foo), Tup())) +//│ TypingUnit(NuFunDef(Some(false), c, N, Nil, L(IntLit(5))), NuTypeDef(Cls, TypeName("Sup"), Ls(), S(Tup((S(Var("a")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup(), Var("a")))))), NuTypeDef(Cls, TypeName("Sub"), Ls(), S(Tup((S(Var("b")), Var("Int")))), N, N, Ls(App(Var("Sup"), Tup((N, App(Var("+"), Tup((N, Var("b")), (N, Var("b")))))))), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("Sub2"), Ls(), S(Tup((S(Var("c")), Var("Int")))), N, N, Ls(App(Var("Sub"), Tup((N, App(Var("+"), Tup((N, Var("c")), (N, Var("c")))))))), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup(), App(Var("+"), Tup((N, Var("a")), (N, Var("c"))))))))), App(Sel(Bra(rcd = false, App(NuNew(Var("Sub")), Tup((N, IntLit(10))))), foo), Tup()), App(Sel(Bra(rcd = false, App(NuNew(Var("Sub2")), Tup((N, Var("c"))))), foo), Tup())) //│ Lifted: //│ TypingUnit { //│ class Sup$1([a: Int,]) {fun foo = () => (this).a} @@ -1152,7 +1152,7 @@ class F2() extends Foo(x => x+2){} (new F1()).foo() (new F2()).foo() //│ Parsed: -//│ TypingUnit(NuTypeDef(class, Foo, (), Tup(f: App(Var(->), Tup(_: Var(Int), _: Var(Int)))), (), None, None, TypingUnit(NuFunDef(None, foo, None, [], Lam(Tup(), App(Var(f), Tup(_: IntLit(1))))))), NuTypeDef(class, F1, (), Tup(), (App(Var(Foo), Tup(_: Lam(Tup(_: Var(x)), App(Var(+), Tup(_: Var(x), _: IntLit(1))))))), None, None, TypingUnit()), NuTypeDef(class, F2, (), Tup(), (App(Var(Foo), Tup(_: Lam(Tup(_: Var(x)), App(Var(+), Tup(_: Var(x), _: IntLit(2))))))), None, None, TypingUnit()), App(Sel(Bra(rcd = false, App(NuNew(Var(F1)), Tup())), foo), Tup()), App(Sel(Bra(rcd = false, App(NuNew(Var(F2)), Tup())), foo), Tup())) +//│ TypingUnit(NuTypeDef(Cls, TypeName("Foo"), Ls(), S(Tup((S(Var("f")), App(Var("->"), Tup((N, Var("Int")), (N, Var("Int"))))))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup(), App(Var("f"), Tup((N, IntLit(1))))))))), NuTypeDef(Cls, TypeName("F1"), Ls(), S(Tup()), N, N, Ls(App(Var("Foo"), Tup((N, Lam(Tup((N, Var("x"))), App(Var("+"), Tup((N, Var("x")), (N, IntLit(1))))))))), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("F2"), Ls(), S(Tup()), N, N, Ls(App(Var("Foo"), Tup((N, Lam(Tup((N, Var("x"))), App(Var("+"), Tup((N, Var("x")), (N, IntLit(2))))))))), N, N, TypingUnit()), App(Sel(Bra(rcd = false, App(NuNew(Var("F1")), Tup())), foo), Tup()), App(Sel(Bra(rcd = false, App(NuNew(Var("F2")), Tup())), foo), Tup())) //│ Lifted: //│ TypingUnit { //│ class Foo$1([f: ->(Int, Int,),]) {fun foo = () => (this).f(1,)} diff --git a/compiler/shared/test/scala/mlscript/compiler/Test.scala b/compiler/shared/test/scala/mlscript/compiler/Test.scala index e0df0d8f0..2e2349bf6 100644 --- a/compiler/shared/test/scala/mlscript/compiler/Test.scala +++ b/compiler/shared/test/scala/mlscript/compiler/Test.scala @@ -3,7 +3,7 @@ package mlscript.compiler import mlscript.utils.shorthands.* import scala.util.control.NonFatal import scala.collection.mutable.StringBuilder -import mlscript.codegen.Helpers.inspect as showStructure +import mlscript.utils.inspect.deep as showStructure import mlscript.{DiffTests, ModeType, TypingUnit} import mlscript.compiler.debug.TreeDebug import mlscript.compiler.mono.Monomorph diff --git a/shared/src/main/scala/mlscript/JSBackend.scala b/shared/src/main/scala/mlscript/JSBackend.scala index 9c8b3d34f..d0ebaddeb 100644 --- a/shared/src/main/scala/mlscript/JSBackend.scala +++ b/shared/src/main/scala/mlscript/JSBackend.scala @@ -1,7 +1,6 @@ package mlscript import mlscript.utils._, shorthands._, algorithms._ -import mlscript.codegen.Helpers._ import mlscript.codegen._ import scala.collection.mutable.{ListBuffer, HashMap, HashSet} import mlscript.{JSField, JSLit} @@ -69,7 +68,7 @@ abstract class JSBackend(allowUnresolvedSymbols: Bool) { case Inst(bod) => translatePattern(bod) case _: Lam | _: App | _: Sel | _: Let | _: Blk | _: Bind | _: Test | _: With | _: CaseOf | _: Subs | _: Assign | If(_, _) | New(_, _) | NuNew(_) | _: Splc | _: Forall | _: Where | _: Super | _: Eqn | _: AdtMatchWith | _: Rft => - throw CodeGenError(s"term ${inspect(t)} is not a valid pattern") + throw CodeGenError(s"term ${inspect.deep(t)} is not a valid pattern") } private def translateParams(t: Term)(implicit scope: Scope): Ls[JSPattern] = t match { @@ -172,7 +171,7 @@ abstract class JSBackend(allowUnresolvedSymbols: Bool) { } callee(args map { case (_, Fld(_, arg)) => translateTerm(arg) }: _*) case App(trm, splice) => ??? // TODO represents `trm(...splice)` - case _ => throw CodeGenError(s"ill-formed application ${inspect(term)}") + case _ => throw CodeGenError(s"ill-formed application ${inspect.deep(term)}") } /** @@ -297,7 +296,7 @@ abstract class JSBackend(allowUnresolvedSymbols: Bool) { case _: Subs | _: Sel | _: Var => JSCommaExpr(JSAssignExpr(translateTerm(lhs), translateTerm(value)) :: JSArray(Nil) :: Nil) case _ => - throw CodeGenError(s"illegal assignemnt left-hand side: ${inspect(lhs)}") + throw CodeGenError(s"illegal assignemnt left-hand side: ${inspect.deep(lhs)}") } case Inst(bod) => translateTerm(bod) case iff: If => @@ -310,7 +309,7 @@ abstract class JSBackend(allowUnresolvedSymbols: Bool) { case n: JSNew => n case t => JSNew(t) } - case _ => throw CodeGenError(s"Unsupported `new` class term: ${inspect(cls)}") + case _ => throw CodeGenError(s"Unsupported `new` class term: ${inspect.deep(cls)}") } // * Would not be quite correct: // JSNew(translateTerm(cls)) @@ -328,7 +327,7 @@ abstract class JSBackend(allowUnresolvedSymbols: Bool) { case Eqn(Var(name), _) => throw CodeGenError(s"assignment of $name is not supported outside a constructor") case _: Bind | _: Test | If(_, _) | _: Splc | _: Where | _: AdtMatchWith | _: Rft => - throw CodeGenError(s"cannot generate code for term ${inspect(term)}") + throw CodeGenError(s"cannot generate code for term ${inspect.deep(term)}") } private def translateCaseBranch(scrut: JSExpr, branch: CaseBranches)(implicit diff --git a/shared/src/main/scala/mlscript/codegen/Helpers.scala b/shared/src/main/scala/mlscript/codegen/Helpers.scala deleted file mode 100644 index 5bade531b..000000000 --- a/shared/src/main/scala/mlscript/codegen/Helpers.scala +++ /dev/null @@ -1,100 +0,0 @@ -package mlscript.codegen - -import mlscript._, mlscript.utils.shorthands._ -import scala.collection.immutable.{Map, Set} - -object Helpers { - /** - * Show how a term is actually structured. - */ - def inspect(t: Terms): Str = t match { - case Var(name) => s"Var($name)" - case Lam(lhs, rhs) => s"Lam(${inspect(lhs)}, ${inspect(rhs)})" - case App(lhs, rhs) => s"App(${inspect(lhs)}, ${inspect(rhs)})" - case Tup(fields) => - val entries = fields map { - case (S(name), Fld(_, value)) => s"$name: ${inspect(value)}" - case (N, Fld(_, value)) => s"_: ${inspect(value)}" - } - s"Tup(${entries mkString ", "})" - case Rcd(fields) => - val entries = fields.iterator - .map { case k -> Fld(_, v) => s"${inspect(k)} = ${inspect(v)}" } - .mkString(", ") - s"Rcd($entries)" - case Sel(receiver, fieldName) => s"Sel(${inspect(receiver)}, $fieldName)" - case Let(isRec, name, rhs, body) => s"Let($isRec, $name, ${inspect(rhs)}, ${inspect(body)})" - case Blk(stmts) => s"Blk(...)" - case Bra(rcd, trm) => s"Bra(rcd = $rcd, ${inspect(trm)})" - case Asc(trm, ty) => s"Asc(${inspect(trm)}, $ty)" - case Bind(lhs, rhs) => s"Bind(${inspect(lhs)}, ${inspect(rhs)})" - case Test(trm, ty) => s"Test(${inspect(trm)}, ${inspect(ty)})" - case With(trm, fields) => - s"With(${inspect(trm)}, ${inspect(fields)})" - case CaseOf(trm, cases) => - def inspectCaseBranches(br: CaseBranches): Str = br match { - case Case(clsNme, body, rest) => - s"Case($clsNme, ${inspect(body)}, ${inspectCaseBranches(rest)})" - case Wildcard(body) => s"Wildcard(${inspect(body)})" - case NoCases => "NoCases" - } - s"CaseOf(${inspect(trm)}, ${inspectCaseBranches(cases)}" - case IntLit(value) => s"IntLit($value)" - case DecLit(value) => s"DecLit($value)" - case StrLit(value) => s"StrLit($value)" - case UnitLit(value) => s"UnitLit($value)" - case Subs(arr, idx) => s"Subs(${inspect(arr)}, ${inspect(idx)})" - case Assign(f, v) => s"Assign(${inspect(f)}, ${inspect(v)})" - case Splc(fs) => - val elems = fs.map{case L(l) => s"...${inspect(l)}" case R(Fld(_, r)) => inspect(r)}.mkString(", ") - s"Splc($elems)" - case If(bod, els) => s"If(${inspect(bod)}, ${els.map(inspect)})" - case New(base, body) => s"New(${base}, ${inspect(body)})" - case NuNew(base) => s"NuNew(${inspect(base)})" - case TyApp(base, targs) => s"TyApp(${inspect(base)}, ${targs})" - case Def(rec, nme, rhs, isByname) => - s"Def($rec, $nme, ${rhs.fold(inspect, "" + _)}, $isByname)" - case Where(bod, sts) => s"Where(${inspect(bod)}, ...)" - case Forall(ps, bod) => s"Forall($ps, ${inspect(bod)})" - case Inst(bod) => s"Inst(${inspect(bod)})" - case Eqn(lhs, rhs) => s"Eqn(${inspect(lhs)}, ${inspect(rhs)})" - case Super() => "Super()" - case AdtMatchWith(cond, arms) => - s"match ${inspect(cond)} with ${arms.map(patmat => s"${inspect(patmat.pat)} -> ${inspect(patmat.rhs)}").mkString(" | ")}" - case Rft(bse, tu) => s"Rft(${inspect(bse)}, ...)" - } - - def inspect(body: IfBody): Str = body match { - case IfElse(expr) => s"IfElse(${inspect(expr)}" - case IfThen(expr, rhs) => s"IfThen(${inspect(expr)}, ${inspect(rhs)}" - case IfBlock(lines) => s"IfBlock(${ - lines.iterator.map { - case L(body) => inspect(body) - case R(NuFunDef(S(isRec), nme, _, _, L(rhs))) => - s"Let($isRec, ${nme.name}, ${inspect(rhs)})" - case R(_) => ??? - }.mkString(";") - })" - case IfOpsApp(lhs, opsRhss) => s"IfOpsApp(${inspect(lhs)}, ${ - opsRhss.iterator.map { case (op, body) => - s"$op -> ${inspect(body)}" - } - }".mkString("; ") - case IfLet(isRec, name, rhs, body) => ??? - case IfOpApp(lhs, op, rhs) => - s"IfOpApp(${inspect(lhs)}, ${inspect(op)}, ${inspect(rhs)}" - } - def inspect(t: TypingUnit): Str = t.entities.iterator - .map { - case term: Term => inspect(term) - case NuFunDef(lt, nme, symNme, targs, L(term)) => - s"NuFunDef(${lt}, ${nme.name}, $symNme, ${targs.mkString("[", ", ", "]")}, ${inspect(term)})" - case NuFunDef(lt, nme, symNme, targs, R(ty)) => - s"NuFunDef(${lt}, ${nme.name}, $symNme, ${targs.mkString("[", ", ", "]")}, $ty)" - case NuTypeDef(kind, nme, tparams, params, ctor, sig, parents, sup, ths, body) => - s"NuTypeDef(${kind.str}, ${nme.name}, ${tparams.mkString("(", ", ", ")")}, ${ - inspect(params.getOrElse(Tup(Nil)))}, ${parents.map(inspect).mkString("(", ", ", ")")}, $sup, $ths, ${inspect(body)})" - case others => others.toString() - } - .mkString("TypingUnit(", ", ", ")") -} diff --git a/shared/src/main/scala/mlscript/utils/inspect.scala b/shared/src/main/scala/mlscript/utils/inspect.scala new file mode 100644 index 000000000..3e4fa7d91 --- /dev/null +++ b/shared/src/main/scala/mlscript/utils/inspect.scala @@ -0,0 +1,182 @@ +package mlscript.utils + +import mlscript._, shorthands._ + +object inspect { + object shallow { + def apply(term: Statement): Str = term match { + case Var(name) => s"Var(\"$name\")" + case literal: Lit => s"Lit(${literal.toString})" + case fd: NuFunDef => fd.isLetRec.fold("fun")(if (_) "let rec" else "let") + " " + fd.nme.name + case td: NuTypeDef => s"${td.kind.str} ${td.nme.name}" + case _ => + val name = term.getClass.getSimpleName + val arity = term.children.length // Imprecise + if (arity === 0) { name } else s"${name}(${(", _" * arity).drop(2)})" + } + + def apply(d: TypingUnit): Str = d.entities.iterator + .map(apply) + .mkString("{", ", ", "}") + } + + object deep { + def apply(t: Opt[Located]): Str = t match { + case N => "N" + case S(l) => s"S(${apply(l)})" + } + + def apply(t: Ls[Located]): Str = t match { + case Nil => "Nil" + case head :: Nil => s"${apply(head)} :: Nil" + case first :: second :: Nil => s"${apply(first)} :: ${apply(second)} :: Nil" + case _ => t.iterator.map(apply).mkString("Ls(", ", ", ")") + } + + def apply[A <: Located, B <: Located](t: Either[A, B]): Str = t match { + case L(value) => s"L(${apply(value)})" + case R(value) => s"R(${apply(value)})" + } + + def apply(t: Located): Str = t match { + case st: Statement => statement(st) + case fl: Field => field(fl) + case ty: TypeLike => typeLike(ty) + case ib: IfBody => ifBody(ib) + case tu: TypingUnit => typingUnit(tu) + case _ => "??" + } + + private def statement(statement: Statement): Str = statement match { + case Def(rec, nme, rhs, isByname) => s"Def($rec, ${apply(nme)}, ${apply(rhs)}, $isByname)" + case TypeDef(kind, nme, tparams, body, mthDecls, mthDefs, positionals, adtInfo) => s"TypeDef(...)" + case Var(name) => s"Var(\"$name\")" + case Lam(lhs, rhs) => s"Lam(${apply(lhs)}, ${apply(rhs)})" + case App(lhs, rhs) => s"App(${apply(lhs)}, ${apply(rhs)})" + case Tup(fields) => + fields.iterator.map { + case (S(name), Fld(_, value)) => s"(S(${apply(name)}), ${apply(value)})" + case (N, Fld(_, value)) => s"(N, ${apply(value)})" + }.mkString("Tup(", ", ", ")") + case Rcd(fields) => + fields.iterator.map { case k -> Fld(_, v) => s"${apply(k)} = ${apply(v)}" }.mkString("Rcd(", ", ", ")") + case Sel(receiver, fieldName) => s"Sel(${apply(receiver)}, $fieldName)" + case Let(isRec, name, rhs, body) => s"Let($isRec, $name, ${apply(rhs)}, ${apply(body)})" + case Blk(stmts) => s"Blk(${stmts.iterator.map(apply).mkString(", ")})" + case Bra(rcd, trm) => s"Bra(rcd = $rcd, ${apply(trm)})" + case Asc(trm, ty) => s"Asc(${apply(trm)}, $ty)" + case Bind(lhs, rhs) => s"Bind(${apply(lhs)}, ${apply(rhs)})" + case Test(trm, ty) => s"Test(${apply(trm)}, ${apply(ty)})" + case With(trm, fields) => + s"With(${apply(trm)}, ${apply(fields)})" + case CaseOf(trm, cases) => + def inspectCaseBranches(br: CaseBranches): Str = br match { + case Case(clsNme, body, rest) => + s"Case($clsNme, ${apply(body)}, ${inspectCaseBranches(rest)})" + case Wildcard(body) => s"Wildcard(${apply(body)})" + case NoCases => "NoCases" + } + s"CaseOf(${apply(trm)}, ${inspectCaseBranches(cases)}" + case IntLit(value) => s"IntLit($value)" + case DecLit(value) => s"DecLit($value)" + case StrLit(value) => s"StrLit($value)" + case UnitLit(value) => s"UnitLit($value)" + case Subs(arr, idx) => s"Subs(${apply(arr)}, ${apply(idx)})" + case Assign(f, v) => s"Assign(${apply(f)}, ${apply(v)})" + case Splc(fs) => + fs.iterator.map{ case L(l) => s"...${apply(l)}" case R(Fld(_, r)) => apply(r)}.mkString("Splc(", ", ", ")") + case If(bod, els) => s"If(${apply(bod)}, ${els.map(apply)})" + case New(base, body) => s"New(${base}, ${apply(body)})" + case NuNew(base) => s"NuNew(${apply(base)})" + case TyApp(base, targs) => s"TyApp(${apply(base)}, ${targs})" + case Where(bod, sts) => s"Where(${apply(bod)}, ...)" + case Forall(ps, bod) => s"Forall($ps, ${apply(bod)})" + case Inst(bod) => s"Inst(${apply(bod)})" + case Eqn(lhs, rhs) => s"Eqn(${apply(lhs)}, ${apply(rhs)})" + case Super() => "Super()" + case AdtMatchWith(cond, arms) => + s"match ${apply(cond)} with ${arms.map(patmat => s"${apply(patmat.pat)} -> ${apply(patmat.rhs)}").mkString(" | ")}" + case Rft(bse, tu) => s"Rft(${apply(bse)}, ${apply(tu)})" + case LetS(isRec, pat, rhs) => s"LetS($isRec, ${apply(pat)}, ${apply(rhs)})" + case DataDefn(body) => s"DataDefn(${apply(body)})" + case DatatypeDefn(head, body) => s"DatatypeDefn(${apply(head)}, ${apply(body)})" + case NuTypeDef(kind, nme, tparams, params, ctor, sig, parents, superAnnot, thisAnnot, body) => + s"NuTypeDef($kind, ${apply(nme)}, Ls(" + + tparams.iterator.map { + case (S(vi), tn) => s"S($vi) -> ${apply(tn)}" + case (N, tn) => s"N -> ${apply(tn)}" + }.mkString(", ") + "), " + + apply(params) + ", " + + apply(ctor) + ", " + + apply(sig) + ", " + + parents.iterator.map(apply).mkString("Ls(", ", ", ")") + ", " + + apply(superAnnot) + ", " + + apply(thisAnnot) + ", " + + apply(body) + ")" + case NuFunDef(isLetRec, nme, symbolicNme, tparams, rhs) => + s"NuFunDef($isLetRec, ${nme.name}, ${apply(symbolicNme)}, ${apply(tparams)}, ${apply(rhs)})" + case Constructor(params, body) => s"Constructor" + } + + private def field(field: Field): Str = field match { + case Field(nme, value) => s"Fld(${apply(nme)}, ${apply(value)})" + } + + private def typeLike(ty: TypeLike): Str = ty match { + case Union(lhs, rhs) => s"Union(${apply(lhs)}, ${apply(rhs)})" + case Inter(lhs, rhs) => s"Inter(${apply(lhs)}, ${apply(rhs)})" + case Function(lhs, rhs) => s"Function(${apply(lhs)}, ${apply(rhs)})" + case Record(fields) => s"Record(${fields.iterator.map { case (nme, ty) => s"$nme: ${apply(ty)}" }.mkString(", ")})" + case Tuple(fields) => s"Tuple(${fields.iterator.map { + case N -> field => s"N -> ${apply(field)}" + case S(nme) -> field => s"S($nme) -> ${apply(field)}" + }.mkString(", ")})" + case Recursive(uv, body) => s"Recursive(${apply(uv)}, ${apply(body)})" + case AppliedType(base, targs) => s"AppliedType(${apply(base)}, ${apply(targs)})" + case Selection(base, name) => s"Selection(${apply(base)}, $name)" + case Neg(base) => s"Neg(${apply(base)})" + case Rem(base, names) => s"Rem(${apply(base)}, ${names.iterator.map(apply).mkString(", ")})" + case Bounds(lb, ub) => s"Bounds(${apply(lb)}, ${apply(ub)})" + case WithExtension(base, rcd) => s"WithExtension(${apply(base)}, ${apply(rcd)})" + case Splice(fields) => s"Splice(${fields.iterator.map { + case L(l) => s"L(${apply(l)})" + case R(f) => s"R(${apply(f)})" + }.mkString(", ")})" + case Constrained(base, tvBounds, where) => s"Constrained(${apply(base)}, Ls(${tvBounds.iterator.map { + case (tv, bounds) => s"${apply(tv)} -> ${apply(bounds)}" + }}), ${apply(where)})" + case Top => "Top" + case Bot => "Bot" + case Literal(lit) => s"Literal(${lit.toString})" + case TypeName(name) => s"TypeName(\"$name\")" + case TypeTag(name) => s"TypeTag($name)" + case TypeVar(identifier, nameHint) => s"TypeVar(${identifier match { + case L(i) => s"L($i)" + case R(n) => s"R($n)" + }}, ${nameHint.fold("N")(n => s"S($n)")})" + case PolyType(targs, body) => s"PolyType(Ls(${targs.iterator.map(_.fold(apply, apply)).mkString(", ")}), ${apply(body)})" + case Signature(members, result) => s"Signature(${members.iterator.map(apply(_: Statement)).mkString("Ls(", ", ", ")")}, ${apply(result)})" + case t: NuDecl => apply(t: Statement) + } + + private def ifBody(body: IfBody): Str = body match { + case IfElse(expr) => s"IfElse(${apply(expr)}" + case IfThen(expr, rhs) => s"IfThen(${apply(expr)}, ${apply(rhs)}" + case IfBlock(lines) => s"IfBlock(${ + lines.iterator.map(_.fold(apply, apply)).mkString("Ls(", ", ", ")") + })" + case IfOpsApp(lhs, opsRhss) => s"IfOpsApp(${apply(lhs)}, ${ + opsRhss.iterator.map { case (op, body) => + s"$op -> ${apply(body)}" + } + }".mkString("; ") + case IfLet(isRec, name, rhs, body) => ??? + case IfOpApp(lhs, op, rhs) => + s"IfOpApp(${apply(lhs)}, ${apply(op)}, ${apply(rhs)}" + } + + private def typingUnit(t: TypingUnit): Str = t.entities.iterator + .map(apply) + .mkString("TypingUnit(", ", ", ")") + } +} \ No newline at end of file diff --git a/shared/src/test/diff/basics/Blocks.fun b/shared/src/test/diff/basics/Blocks.fun index 65d88924e..3d0a46eeb 100644 --- a/shared/src/test/diff/basics/Blocks.fun +++ b/shared/src/test/diff/basics/Blocks.fun @@ -44,7 +44,7 @@ discard / foo 1 //│ Parsed: discard(...(foo(...{1}))); //│ Desugared: discard(...(foo(...{1}))) -//│ AST: App(Var(discard), App(Var(foo), Blk(...))) +//│ AST: App(Var("discard"), App(Var("foo"), Blk(IntLit(1)))) :e discard foo @@ -81,7 +81,7 @@ id id id //│ Parsed: id(...id)(...{id}); //│ Desugared: id(...id)(...{id}) -//│ AST: App(App(Var(id), Var(id)), Blk(...)) +//│ AST: App(App(Var("id"), Var("id")), Blk(Var("id"))) //│ res: 'a -> 'a :p @@ -91,7 +91,7 @@ id id id id id id //│ Parsed: id(...id)(...id)(...{id(...id)(...id)(...{id(...id)(...id)(...{id(...id)(...id)})})}); //│ Desugared: id(...id)(...id)(...{id(...id)(...id)(...{id(...id)(...id)(...{id(...id)(...id)})})}) -//│ AST: App(App(App(Var(id), Var(id)), Var(id)), Blk(...)) +//│ AST: App(App(App(Var("id"), Var("id")), Var("id")), Blk(App(App(App(Var("id"), Var("id")), Var("id")), Blk(App(App(App(Var("id"), Var("id")), Var("id")), Blk(App(App(Var("id"), Var("id")), Var("id")))))))) //│ res: 'a -> 'a :p @@ -100,7 +100,7 @@ id id / id id //│ Parsed: id(...id)(...{id(...id)(...{id(...id)})}); //│ Desugared: id(...id)(...{id(...id)(...{id(...id)})}) -//│ AST: App(App(Var(id), Var(id)), Blk(...)) +//│ AST: App(App(Var("id"), Var("id")), Blk(App(App(Var("id"), Var("id")), Blk(App(Var("id"), Var("id")))))) //│ res: 'a -> 'a :p @@ -109,7 +109,7 @@ id id id id //│ Parsed: id(...id)(...{id(...id)})(...{id(...id)}); //│ Desugared: id(...id)(...{id(...id)})(...{id(...id)}) -//│ AST: App(App(App(Var(id), Var(id)), Blk(...)), Blk(...)) +//│ AST: App(App(App(Var("id"), Var("id")), Blk(App(Var("id"), Var("id")))), Blk(App(Var("id"), Var("id")))) //│ res: 'a -> 'a let foo = diff --git a/shared/src/test/diff/basics/Data.fun b/shared/src/test/diff/basics/Data.fun index f155732ee..d30a7ba97 100644 --- a/shared/src/test/diff/basics/Data.fun +++ b/shared/src/test/diff/basics/Data.fun @@ -4,7 +4,7 @@ data Test a b //│ Parsed: data Test(...a)(...b); //│ Desugared: class Test[a, b]: {a: a, b: b} //│ Desugared: def Test: forall a b. (...a) -> (...b) -> Test[a, b] -//│ AST: Def(false, Test, PolyType(List(Left(TypeName(a)), Left(TypeName(b))),Function(TypeName(a),Function(TypeName(b),AppliedType(TypeName(Test),List(TypeName(a), TypeName(b)))))), true) +//│ AST: Def(false, Var("Test"), R(PolyType(Ls(TypeName("a"), TypeName("b")), Function(TypeName("a"), Function(TypeName("b"), AppliedType(TypeName("Test"), TypeName("a") :: TypeName("b") :: Nil))))), true) //│ Defined class Test[+a, +b] //│ Test: 'a -> 'b -> Test['a, 'b] @@ -13,7 +13,7 @@ data Person(name: string, age: int) //│ Parsed: data Person(...'(' {[name: string, age: int,]} ')'); //│ Desugared: class Person: {age: int, name: string} //│ Desugared: def Person: (name: string, age: int) -> Person[] -//│ AST: Def(false, Person, PolyType(List(),Function(Tuple(List((Some(name),Field(None,TypeName(string))), (Some(age),Field(None,TypeName(int))))),AppliedType(TypeName(Person),List()))), true) +//│ AST: Def(false, Var("Person"), R(PolyType(Ls(), Function(Tuple(S(name) -> Fld(N, TypeName("string")), S(age) -> Fld(N, TypeName("int"))), AppliedType(TypeName("Person"), Nil)))), true) //│ Defined class Person //│ Person: (name: string, age: int,) -> Person diff --git a/shared/src/test/diff/basics/Datatypes.fun b/shared/src/test/diff/basics/Datatypes.fun index 2b2b0e737..89f0a6899 100644 --- a/shared/src/test/diff/basics/Datatypes.fun +++ b/shared/src/test/diff/basics/Datatypes.fun @@ -6,9 +6,9 @@ data type Boolean of Tru, Fals //│ Desugared: class Tru: {} //│ Desugared: class Fals: {} //│ Desugared: def Tru: Tru[] -//│ AST: Def(false, Tru, PolyType(List(),AppliedType(TypeName(Tru),List())), true) +//│ AST: Def(false, Var("Tru"), R(PolyType(Ls(), AppliedType(TypeName("Tru"), Nil))), true) //│ Desugared: def Fals: Fals[] -//│ AST: Def(false, Fals, PolyType(List(),AppliedType(TypeName(Fals),List())), true) +//│ AST: Def(false, Var("Fals"), R(PolyType(Ls(), AppliedType(TypeName("Fals"), Nil))), true) //│ Defined type alias Boolean //│ Defined class Tru //│ Defined class Fals @@ -29,7 +29,7 @@ data type Bool2 of True2 & False2 //│ Desugared: type alias Bool2 = &[True2, False2] //│ Desugared: class &[True2, False2]: {False2 <: False2, True2 <: True2} //│ Desugared: def &: forall True2 False2. (...True2) -> (...False2) -> &[True2, False2] -//│ AST: Def(false, &, PolyType(List(Left(TypeName(True2)), Left(TypeName(False2))),Function(TypeName(True2),Function(TypeName(False2),AppliedType(TypeName(&),List(TypeName(True2), TypeName(False2)))))), true) +//│ AST: Def(false, Var("&"), R(PolyType(Ls(TypeName("True2"), TypeName("False2")), Function(TypeName("True2"), Function(TypeName("False2"), AppliedType(TypeName("&"), TypeName("True2") :: TypeName("False2") :: Nil))))), true) //│ ╔══[ERROR] type identifier not found: True2 //│ ║ l.27: data type Bool2 of True2 & False2 //│ ╙── ^^^^^ @@ -122,9 +122,9 @@ data type List a of //│ Desugared: class Nil[a]: {} //│ Desugared: class Cons[a]: {head: a, tail: anything} //│ Desugared: def Nil: forall a. Nil[a] -//│ AST: Def(false, Nil, PolyType(List(Left(TypeName(a))),AppliedType(TypeName(Nil),List(TypeName(a)))), true) +//│ AST: Def(false, Var("Nil"), R(PolyType(Ls(TypeName("a")), AppliedType(TypeName("Nil"), TypeName("a") :: Nil))), true) //│ Desugared: def Cons: forall a. (head: a) -> (tail: anything) -> Cons[a] -//│ AST: Def(false, Cons, PolyType(List(Left(TypeName(a))),Function(Tuple(List((Some(head),Field(None,TypeName(a))))),Function(Tuple(List((Some(tail),Field(None,Top)))),AppliedType(TypeName(Cons),List(TypeName(a)))))), true) +//│ AST: Def(false, Var("Cons"), R(PolyType(Ls(TypeName("a")), Function(Tuple(S(head) -> Fld(N, TypeName("a"))), Function(Tuple(S(tail) -> Fld(N, Top)), AppliedType(TypeName("Cons"), TypeName("a") :: Nil))))), true) //│ Defined type alias List[+a] //│ Defined class Nil[±a] //│ Defined class Cons[+a] @@ -144,7 +144,7 @@ data type Ls of LsA a //│ Desugared: type alias Ls = LsA[a] //│ Desugared: class LsA[a]: {a: a} //│ Desugared: def LsA: forall a. (...a) -> LsA[a] -//│ AST: Def(false, LsA, PolyType(List(Left(TypeName(a))),Function(TypeName(a),AppliedType(TypeName(LsA),List(TypeName(a))))), true) +//│ AST: Def(false, Var("LsA"), R(PolyType(Ls(TypeName("a")), Function(TypeName("a"), AppliedType(TypeName("LsA"), TypeName("a") :: Nil)))), true) //│ ╔══[ERROR] type identifier not found: a //│ ║ l.142: data type Ls of LsA a //│ ╙── ^ @@ -159,7 +159,7 @@ data type Ls2 of LsA2 `a //│ Desugared: type alias Ls2 = LsA2[] //│ Desugared: class LsA2: {`a: 'a} //│ Desugared: def LsA2: (...'a) -> LsA2[] -//│ AST: Def(false, LsA2, PolyType(List(),Function(a,AppliedType(TypeName(LsA2),List()))), true) +//│ AST: Def(false, Var("LsA2"), R(PolyType(Ls(), Function(TypeVar(R(a), N), AppliedType(TypeName("LsA2"), Nil)))), true) //│ ╔══[ERROR] cannot inherit from a polymorphic type //│ ║ l.157: data type Ls2 of LsA2 `a //│ ╙── ^^^^^^^ diff --git a/shared/src/test/diff/basics/Either.fun b/shared/src/test/diff/basics/Either.fun index 7ea04bae6..02a365567 100644 --- a/shared/src/test/diff/basics/Either.fun +++ b/shared/src/test/diff/basics/Either.fun @@ -9,9 +9,9 @@ data type Either l r of //│ Desugared: class Left[l, r]: {l: l} //│ Desugared: class Right[l, r]: {r: r} //│ Desugared: def Left: forall l r. (...l) -> Left[l, r] -//│ AST: Def(false, Left, PolyType(List(Left(TypeName(l)), Left(TypeName(r))),Function(TypeName(l),AppliedType(TypeName(Left),List(TypeName(l), TypeName(r))))), true) +//│ AST: Def(false, Var("Left"), R(PolyType(Ls(TypeName("l"), TypeName("r")), Function(TypeName("l"), AppliedType(TypeName("Left"), TypeName("l") :: TypeName("r") :: Nil)))), true) //│ Desugared: def Right: forall l r. (...r) -> Right[l, r] -//│ AST: Def(false, Right, PolyType(List(Left(TypeName(l)), Left(TypeName(r))),Function(TypeName(r),AppliedType(TypeName(Right),List(TypeName(l), TypeName(r))))), true) +//│ AST: Def(false, Var("Right"), R(PolyType(Ls(TypeName("l"), TypeName("r")), Function(TypeName("r"), AppliedType(TypeName("Right"), TypeName("l") :: TypeName("r") :: Nil)))), true) //│ Defined type alias Either[+l, +r] //│ Defined class Left[+l, ±r] //│ Defined class Right[±l, +r] diff --git a/shared/src/test/diff/basics/Flow.fun b/shared/src/test/diff/basics/Flow.fun index 5005f8a42..16b7c5a1d 100644 --- a/shared/src/test/diff/basics/Flow.fun +++ b/shared/src/test/diff/basics/Flow.fun @@ -6,9 +6,9 @@ data R x //│ Desugared: class L[x]: {x: x} //│ Desugared: class R[x]: {x: x} //│ Desugared: def L: forall x. (...x) -> L[x] -//│ AST: Def(false, L, PolyType(List(Left(TypeName(x))),Function(TypeName(x),AppliedType(TypeName(L),List(TypeName(x))))), true) +//│ AST: Def(false, Var("L"), R(PolyType(Ls(TypeName("x")), Function(TypeName("x"), AppliedType(TypeName("L"), TypeName("x") :: Nil)))), true) //│ Desugared: def R: forall x. (...x) -> R[x] -//│ AST: Def(false, R, PolyType(List(Left(TypeName(x))),Function(TypeName(x),AppliedType(TypeName(R),List(TypeName(x))))), true) +//│ AST: Def(false, Var("R"), R(PolyType(Ls(TypeName("x")), Function(TypeName("x"), AppliedType(TypeName("R"), TypeName("x") :: Nil)))), true) //│ Defined class L[+x] //│ Defined class R[+x] //│ L: 'a -> L['a] diff --git a/shared/src/test/diff/basics/Operators.fun b/shared/src/test/diff/basics/Operators.fun index bbf5eff5c..845354e70 100644 --- a/shared/src/test/diff/basics/Operators.fun +++ b/shared/src/test/diff/basics/Operators.fun @@ -16,7 +16,7 @@ a + b //│ Parsed: +(...a)(...{b}); //│ Desugared: +(...a)(...{b}) -//│ AST: App(App(Var(+), Var(a)), Blk(...)) +//│ AST: App(App(Var("+"), Var("a")), Blk(Var("b"))) //│ res: int :pe @@ -31,7 +31,7 @@ succ a + c //│ Parsed: +(...(succ(...a)))(...{+(...b)(...{c})}); //│ Desugared: +(...(succ(...a)))(...{+(...b)(...{c})}) -//│ AST: App(App(Var(+), App(Var(succ), Var(a))), Blk(...)) +//│ AST: App(App(Var("+"), App(Var("succ"), Var("a"))), Blk(App(App(Var("+"), Var("b")), Blk(Var("c"))))) //│ res: int :p @@ -40,7 +40,7 @@ succ / a + c //│ Parsed: succ(...(+(...a)(...{+(...b)(...{c})}))); //│ Desugared: succ(...(+(...a)(...{+(...b)(...{c})}))) -//│ AST: App(Var(succ), App(App(Var(+), Var(a)), Blk(...))) +//│ AST: App(Var("succ"), App(App(Var("+"), Var("a")), Blk(App(App(Var("+"), Var("b")), Blk(Var("c")))))) //│ res: int :p @@ -55,11 +55,11 @@ a + d //│ Parsed: +(...a)(...b); +(...(+(...a)(...b)))(...c); +(...(+(...(+(...a)(...b)))(...c)))(...d); //│ Desugared: +(...a)(...b) -//│ AST: App(App(Var(+), Var(a)), Var(b)) +//│ AST: App(App(Var("+"), Var("a")), Var("b")) //│ Desugared: +(...(+(...a)(...b)))(...c) -//│ AST: App(App(Var(+), App(App(Var(+), Var(a)), Var(b))), Var(c)) +//│ AST: App(App(Var("+"), App(App(Var("+"), Var("a")), Var("b"))), Var("c")) //│ Desugared: +(...(+(...(+(...a)(...b)))(...c)))(...d) -//│ AST: App(App(Var(+), App(App(Var(+), App(App(Var(+), Var(a)), Var(b))), Var(c))), Var(d)) +//│ AST: App(App(Var("+"), App(App(Var("+"), App(App(Var("+"), Var("a")), Var("b"))), Var("c"))), Var("d")) //│ res: int //│ res: int //│ res: int @@ -74,7 +74,7 @@ a + d //│ Parsed: +(...(+(...(+(...a)(...b)))(...(+(...(+(...c)(...1)))(...(+(...2)(...3)))))))(...d); //│ Desugared: +(...(+(...(+(...a)(...b)))(...(+(...(+(...c)(...1)))(...(+(...2)(...3)))))))(...d) -//│ AST: App(App(Var(+), App(App(Var(+), App(App(Var(+), Var(a)), Var(b))), App(App(Var(+), App(App(Var(+), Var(c)), IntLit(1))), App(App(Var(+), IntLit(2)), IntLit(3))))), Var(d)) +//│ AST: App(App(Var("+"), App(App(Var("+"), App(App(Var("+"), Var("a")), Var("b"))), App(App(Var("+"), App(App(Var("+"), Var("c")), IntLit(1))), App(App(Var("+"), IntLit(2)), IntLit(3))))), Var("d")) //│ res: int :pe @@ -112,7 +112,7 @@ succ + c //│ Parsed: +(...(succ(...{+(...a)(...b)})))(...c); //│ Desugared: +(...(succ(...{+(...a)(...b)})))(...c) -//│ AST: App(App(Var(+), App(Var(succ), Blk(...))), Var(c)) +//│ AST: App(App(Var("+"), App(Var("succ"), Blk(App(App(Var("+"), Var("a")), Var("b"))))), Var("c")) //│ res: int // Maybe allow this as it lets us nicely align the operands? diff --git a/shared/src/test/diff/basics/Slashes.fun b/shared/src/test/diff/basics/Slashes.fun index ef7aef704..09db214d6 100644 --- a/shared/src/test/diff/basics/Slashes.fun +++ b/shared/src/test/diff/basics/Slashes.fun @@ -23,7 +23,7 @@ x => succ / succ / x + 1 foo / x => succ / succ / x //│ Parsed: foo(...((...x) => succ(...(succ(...x))))); //│ Desugared: foo(...((...x) => succ(...(succ(...x))))) -//│ AST: App(Var(foo), Lam(Var(x), App(Var(succ), App(Var(succ), Var(x))))) +//│ AST: App(Var("foo"), Lam(Var("x"), App(Var("succ"), App(Var("succ"), Var("x"))))) //│ res: int :e diff --git a/shared/src/test/diff/mlscript/Basics.mls b/shared/src/test/diff/mlscript/Basics.mls index 2af98bf08..2fb3e1b4a 100644 --- a/shared/src/test/diff/mlscript/Basics.mls +++ b/shared/src/test/diff/mlscript/Basics.mls @@ -96,7 +96,7 @@ def f (x y z) = add x y //│ ╙── ^^^^^ //│ f: error -> int //│ Code generation encountered an error: -//│ term App(App(Var(x), Tup(_: Var(y))), Tup(_: Var(z))) is not a valid pattern +//│ term App(App(Var("x"), Tup((N, Var("y")))), Tup((N, Var("z")))) is not a valid pattern f 1 //│ res: int diff --git a/shared/src/test/diff/mlscript/ByNameByValue.mls b/shared/src/test/diff/mlscript/ByNameByValue.mls index 3e8764077..5d4816180 100644 --- a/shared/src/test/diff/mlscript/ByNameByValue.mls +++ b/shared/src/test/diff/mlscript/ByNameByValue.mls @@ -16,7 +16,7 @@ def incr x = x.a <- x.a + 1 def gensym = let n = { mut a = 0 } in fun () -> (incr n, n) //│ Parsed: def gensym: let n = {mut a: 0} in () => [incr(n,), n,]; //│ Desugared: def gensym: let n = {mut a: 0} in () => [incr(n,), n,] -//│ AST: Def(false, gensym, Let(false, n, Rcd(Var(a) = IntLit(0)), Lam(Tup(), Tup(_: App(Var(incr), Tup(_: Var(n))), _: Var(n)))), true) +//│ AST: Def(false, Var("gensym"), L(Let(false, n, Rcd(Var("a") = IntLit(0)), Lam(Tup(), Tup((N, App(Var("incr"), Tup((N, Var("n"))))), (N, Var("n")))))), true) //│ // Query 1 //│ globalThis.gensym = function gensym() { //│ return (((n) => () => [ @@ -35,7 +35,7 @@ def gensym = let n = { mut a = 0 } in fun () -> (incr n, n) gensym1 = let n = { mut a = 0 } in fun () -> (incr n, n) //│ Parsed: let gensym1 = let n = {mut a: 0} in () => [incr(n,), n,]; //│ Desugared: def gensym1: let n = {mut a: 0} in () => [incr(n,), n,] -//│ AST: Def(false, gensym1, Let(false, n, Rcd(Var(a) = IntLit(0)), Lam(Tup(), Tup(_: App(Var(incr), Tup(_: Var(n))), _: Var(n)))), false) +//│ AST: Def(false, Var("gensym1"), L(Let(false, n, Rcd(Var("a") = IntLit(0)), Lam(Tup(), Tup((N, App(Var("incr"), Tup((N, Var("n"))))), (N, Var("n")))))), false) //│ // Query 1 //│ globalThis.gensym1 = ((n) => () => [ //│ incr(n), diff --git a/shared/src/test/diff/mlscript/MultiArgs.mls b/shared/src/test/diff/mlscript/MultiArgs.mls index 62e7a8090..738d35676 100644 --- a/shared/src/test/diff/mlscript/MultiArgs.mls +++ b/shared/src/test/diff/mlscript/MultiArgs.mls @@ -75,9 +75,9 @@ f = fun (x, y) -> add x y f(1, 2) //│ Parsed: let f = (x, y,) => add(x,)(y,); f(1, 2,); //│ Desugared: def f: (x, y,) => add(x,)(y,) -//│ AST: Def(false, f, Lam(Tup(_: Var(x), _: Var(y)), App(App(Var(add), Tup(_: Var(x))), Tup(_: Var(y)))), false) +//│ AST: Def(false, Var("f"), L(Lam(Tup((N, Var("x")), (N, Var("y"))), App(App(Var("add"), Tup((N, Var("x")))), Tup((N, Var("y")))))), false) //│ Desugared: f(1, 2,) -//│ AST: App(Var(f), Tup(_: IntLit(1), _: IntLit(2))) +//│ AST: App(Var("f"), Tup((N, IntLit(1)), (N, IntLit(2)))) //│ f: (int, int,) -> int //│ = [Function: f] //│ res: int @@ -119,9 +119,9 @@ f = fun ((x, y)) -> add x y f((1, 2)) //│ Parsed: let f = ('(' [x, y,] ')',) => add(x,)(y,); f('(' [1, 2,] ')',); //│ Desugared: def f: ('(' [x, y,] ')',) => add(x,)(y,) -//│ AST: Def(false, f, Lam(Tup(_: Bra(rcd = false, Tup(_: Var(x), _: Var(y)))), App(App(Var(add), Tup(_: Var(x))), Tup(_: Var(y)))), false) +//│ AST: Def(false, Var("f"), L(Lam(Tup((N, Bra(rcd = false, Tup((N, Var("x")), (N, Var("y")))))), App(App(Var("add"), Tup((N, Var("x")))), Tup((N, Var("y")))))), false) //│ Desugared: f('(' [1, 2,] ')',) -//│ AST: App(Var(f), Tup(_: Bra(rcd = false, Tup(_: IntLit(1), _: IntLit(2))))) +//│ AST: App(Var("f"), Tup((N, Bra(rcd = false, Tup((N, IntLit(1)), (N, IntLit(2))))))) //│ f: ((int, int,),) -> int //│ = [Function: f1] //│ res: int diff --git a/shared/src/test/diff/mlscript/Mut.mls b/shared/src/test/diff/mlscript/Mut.mls index 5abffdda4..20bb9fc22 100644 --- a/shared/src/test/diff/mlscript/Mut.mls +++ b/shared/src/test/diff/mlscript/Mut.mls @@ -613,7 +613,7 @@ b1.x <- 1 + 2 <- 4 //│ ║ l.550: b1.x <- 1 + 2 <- 4 //│ ╙── ^ //│ Code generation encountered an error: -//│ illegal assignemnt left-hand side: Bra(rcd = false, Assign(Sel(Var(mt1), 0), Sel(Var(b1), t))) +//│ illegal assignemnt left-hand side: Bra(rcd = false, Assign(Sel(Var("mt1"), 0), Sel(Var("b1"), t))) def f : {mut 0 : int} -> int -> unit def g : (mut int, bool) -> int -> unit diff --git a/shared/src/test/diff/mlscript/Ops.mls b/shared/src/test/diff/mlscript/Ops.mls index 837b2c09e..f0ea6554d 100644 --- a/shared/src/test/diff/mlscript/Ops.mls +++ b/shared/src/test/diff/mlscript/Ops.mls @@ -3,7 +3,7 @@ 2 + 2 //│ Parsed: +(2,)(2,); //│ Desugared: +(2,)(2,) -//│ AST: App(App(Var(+), Tup(_: IntLit(2))), Tup(_: IntLit(2))) +//│ AST: App(App(Var("+"), Tup((N, IntLit(2)))), Tup((N, IntLit(2)))) //│ res: int //│ = 4 @@ -11,7 +11,7 @@ 1 + 2 * 2 + 3 //│ Parsed: +(+(1,)(*(2,)(2,),),)(3,); //│ Desugared: +(+(1,)(*(2,)(2,),),)(3,) -//│ AST: App(App(Var(+), Tup(_: App(App(Var(+), Tup(_: IntLit(1))), Tup(_: App(App(Var(*), Tup(_: IntLit(2))), Tup(_: IntLit(2))))))), Tup(_: IntLit(3))) +//│ AST: App(App(Var("+"), Tup((N, App(App(Var("+"), Tup((N, IntLit(1)))), Tup((N, App(App(Var("*"), Tup((N, IntLit(2)))), Tup((N, IntLit(2)))))))))), Tup((N, IntLit(3)))) //│ res: int //│ = 8 @@ -20,7 +20,7 @@ 1 + 2 / 2 + 3 //│ Parsed: +(+(1,)(/(2,)(2,),),)(3,); //│ Desugared: +(+(1,)(/(2,)(2,),),)(3,) -//│ AST: App(App(Var(+), Tup(_: App(App(Var(+), Tup(_: IntLit(1))), Tup(_: App(App(Var(/), Tup(_: IntLit(2))), Tup(_: IntLit(2))))))), Tup(_: IntLit(3))) +//│ AST: App(App(Var("+"), Tup((N, App(App(Var("+"), Tup((N, IntLit(1)))), Tup((N, App(App(Var("/"), Tup((N, IntLit(2)))), Tup((N, IntLit(2)))))))))), Tup((N, IntLit(3)))) //│ ╔══[ERROR] Type mismatch in operator application: //│ ║ l.20: 1 + 2 / 2 + 3 //│ ║ ^^^^^^^^^ @@ -36,7 +36,7 @@ 1 |> 2 || 3 //│ Parsed: ||(|>(1,)(2,),)(3,); //│ Desugared: ||(|>(1,)(2,),)(3,) -//│ AST: App(App(Var(||), Tup(_: App(App(Var(|>), Tup(_: IntLit(1))), Tup(_: IntLit(2))))), Tup(_: IntLit(3))) +//│ AST: App(App(Var("||"), Tup((N, App(App(Var("|>"), Tup((N, IntLit(1)))), Tup((N, IntLit(2))))))), Tup((N, IntLit(3)))) //│ ╔══[ERROR] identifier not found: |> //│ ║ l.36: 1 |> 2 || 3 //│ ╙── ^^ @@ -54,7 +54,7 @@ true || false && true || false //│ Parsed: ||(||(true,)(&&(false,)(true,),),)(false,); //│ Desugared: ||(||(true,)(&&(false,)(true,),),)(false,) -//│ AST: App(App(Var(||), Tup(_: App(App(Var(||), Tup(_: Var(true))), Tup(_: App(App(Var(&&), Tup(_: Var(false))), Tup(_: Var(true))))))), Tup(_: Var(false))) +//│ AST: App(App(Var("||"), Tup((N, App(App(Var("||"), Tup((N, Var("true")))), Tup((N, App(App(Var("&&"), Tup((N, Var("false")))), Tup((N, Var("true")))))))))), Tup((N, Var("false")))) //│ res: bool //│ = true diff --git a/shared/src/test/diff/mlscript/Weird.mls b/shared/src/test/diff/mlscript/Weird.mls index 9aa518f72..ffc7a116c 100644 --- a/shared/src/test/diff/mlscript/Weird.mls +++ b/shared/src/test/diff/mlscript/Weird.mls @@ -41,7 +41,7 @@ class C def n: C{} //│ Parsed: rec def n: C; {}; //│ Desugared: rec def n: C -//│ AST: Def(true, n, PolyType(List(),TypeName(C)), true) +//│ AST: Def(true, Var("n"), R(PolyType(Ls(), TypeName("C"))), true) //│ Desugared: {} //│ AST: Rcd() //│ n: C diff --git a/shared/src/test/diff/nu/AbstractClasses.mls b/shared/src/test/diff/nu/AbstractClasses.mls index ab09dd59b..c00679e1b 100644 --- a/shared/src/test/diff/nu/AbstractClasses.mls +++ b/shared/src/test/diff/nu/AbstractClasses.mls @@ -51,7 +51,7 @@ new Foo(1) { fun f = id } //│ ╙── ^^^^^^^^^^^^^^^^^^^^^^^^^ //│ error //│ Code generation encountered an error: -//│ cannot generate code for term Rft(App(NuNew(Var(Foo)), Tup(_: IntLit(1))), ...) +//│ cannot generate code for term Rft(App(NuNew(Var("Foo")), Tup((N, IntLit(1)))), TypingUnit(NuFunDef(None, f, N, Nil, L(Var("id"))))) abstract class Bar extends Foo(1) diff --git a/shared/src/test/diff/nu/BadBlocks.mls b/shared/src/test/diff/nu/BadBlocks.mls index eedcd08df..03fb69ccf 100644 --- a/shared/src/test/diff/nu/BadBlocks.mls +++ b/shared/src/test/diff/nu/BadBlocks.mls @@ -176,5 +176,5 @@ fun test = (new { //│ ╙── ^ //│ fun test: error //│ Code generation encountered an error: -//│ Unsupported `new` class term: Bra(rcd = true, Rcd(Var(res) = Var(res))) +//│ Unsupported `new` class term: Bra(rcd = true, Rcd(Var("res") = Var("res"))) diff --git a/shared/src/test/diff/nu/LamPatterns.mls b/shared/src/test/diff/nu/LamPatterns.mls index cb78cf349..98bb1511b 100644 --- a/shared/src/test/diff/nu/LamPatterns.mls +++ b/shared/src/test/diff/nu/LamPatterns.mls @@ -14,7 +14,7 @@ Some(x) => x //│ ╙── ^ //│ error -> error //│ Code generation encountered an error: -//│ term App(Var(Some), Tup(_: Var(x))) is not a valid pattern +//│ term App(Var("Some"), Tup((N, Var("x")))) is not a valid pattern :js // FIXME type diff --git a/shared/src/test/diff/nu/LetRec.mls b/shared/src/test/diff/nu/LetRec.mls index 74f8a3f58..51ad7c37f 100644 --- a/shared/src/test/diff/nu/LetRec.mls +++ b/shared/src/test/diff/nu/LetRec.mls @@ -129,7 +129,7 @@ let rec lol = () => lol :p let rec f = 1 //│ |#let| |#rec| |f| |#=| |1| -//│ AST: TypingUnit(NuFunDef(Some(true), f, None, [], IntLit(1))) +//│ AST: TypingUnit(NuFunDef(Some(true), f, N, Nil, L(IntLit(1)))) //│ Parsed: let rec f = 1; //│ let rec f: 1 //│ f diff --git a/shared/src/test/diff/nu/NewNew.mls b/shared/src/test/diff/nu/NewNew.mls index 8ab334a69..86753b6e3 100644 --- a/shared/src/test/diff/nu/NewNew.mls +++ b/shared/src/test/diff/nu/NewNew.mls @@ -167,7 +167,7 @@ new PoInt['_] //│ ╙── ^ //│ PoInt[nothing] | error //│ Code generation encountered an error: -//│ Unsupported `new` class term: TyApp(Var(PoInt), List('_)) +//│ Unsupported `new` class term: TyApp(Var("PoInt"), List('_)) :e new PoInt[Str](0, 0) @@ -176,7 +176,7 @@ new PoInt[Str](0, 0) //│ ╙── ^^^^^^^^^^^^^^^^^^^^ //│ PoInt[0] //│ Code generation encountered an error: -//│ Unsupported `new` class term: TyApp(Var(PoInt), List(TypeName(Str))) +//│ Unsupported `new` class term: TyApp(Var("PoInt"), List(TypeName(Str))) type T = PoInt[Str] //│ type T = PoInt[Str] @@ -211,7 +211,7 @@ let origin = new PoInt[Int](0, 0) //│ ╙── ^^^^^^^^^^^^^^^^^^^^ //│ let origin: PoInt[0] //│ Code generation encountered an error: -//│ Unsupported `new` class term: TyApp(Var(PoInt), List(TypeName(Int))) +//│ Unsupported `new` class term: TyApp(Var("PoInt"), List(TypeName(Int))) :e // TODO support @@ -247,7 +247,7 @@ new //│ ╙── ^ //│ error //│ Code generation encountered an error: -//│ Unsupported `new` class term: Blk(...) +//│ Unsupported `new` class term: Blk(Asc(Var("x"), Literal(0))) @@ -302,6 +302,6 @@ module A { class B } new A.B //│ B //│ Code generation encountered an error: -//│ Unsupported `new` class term: Sel(Var(A), B) +//│ Unsupported `new` class term: Sel(Var("A"), B) diff --git a/shared/src/test/diff/nu/OpLam.mls b/shared/src/test/diff/nu/OpLam.mls index 15b57dbca..ec57b8f85 100644 --- a/shared/src/test/diff/nu/OpLam.mls +++ b/shared/src/test/diff/nu/OpLam.mls @@ -107,6 +107,6 @@ x => x.y => y //│ ╙── ^ //│ anything -> error -> error //│ Code generation encountered an error: -//│ term Sel(Var(x), y) is not a valid pattern +//│ term Sel(Var("x"), y) is not a valid pattern diff --git a/shared/src/test/diff/nu/OverrideShorthand.mls b/shared/src/test/diff/nu/OverrideShorthand.mls index 25db2319d..8383f5a73 100644 --- a/shared/src/test/diff/nu/OverrideShorthand.mls +++ b/shared/src/test/diff/nu/OverrideShorthand.mls @@ -10,7 +10,7 @@ class Pair(lhs: Int, rhs: Int) :e fun f(override Pair(x, y)) = x + y //│ |#fun| |f|(|#override| |Pair|(|x|,| |y|)|)| |#=| |x| |+| |y| -//│ AST: TypingUnit(NuFunDef(None, f, None, [], Lam(Tup(_: Var(_$0)), If(IfOpApp(Var(_$0), Var(is), IfThen(App(Var(Pair), Tup(_: Var(x), _: Var(y))), App(Var(+), Tup(_: Var(x), _: Var(y))), Some(App(Sel(Super(), f), Tup(_: Var(_$0)))))))) +//│ AST: TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("_$0"))), If(IfOpApp(Var("_$0"), Var("is"), IfThen(App(Var("Pair"), Tup((N, Var("x")), (N, Var("y")))), App(Var("+"), Tup((N, Var("x")), (N, Var("y")))), Some(App(Sel(Super(), f), Tup((N, Var("_$0")))))))))) //│ Parsed: fun f = (_$0,) => if _$0 is (Pair(x, y,)) then +(x, y,) else (super).f(_$0,); //│ ╔══[ERROR] identifier not found: super //│ ║ l.11: fun f(override Pair(x, y)) = x + y @@ -46,7 +46,7 @@ fun f(override Pair(x, y), z) = x + y //│ ╙── ^ //│ fun f: (error, anything) -> Int //│ Code generation encountered an error: -//│ term App(Var(Pair), Tup(_: Var(x), _: Var(y))) is not a valid pattern +//│ term App(Var("Pair"), Tup((N, Var("x")), (N, Var("y")))) is not a valid pattern // TODO diff --git a/shared/src/test/diff/nu/RightAssocOps.mls b/shared/src/test/diff/nu/RightAssocOps.mls index 15a34aaad..df5969158 100644 --- a/shared/src/test/diff/nu/RightAssocOps.mls +++ b/shared/src/test/diff/nu/RightAssocOps.mls @@ -30,7 +30,7 @@ fun (++) conc(xs, ys) = [xs, ys] :p 1 +: "a" ++ "b" :+ 2 //│ |1| |+:| |"a"| |++| |"b"| |:+| |2| -//│ AST: TypingUnit(App(Var(+:), Tup(_: IntLit(1), _: App(Var(:+), Tup(_: App(Var(++), Tup(_: StrLit(a), _: StrLit(b))), _: IntLit(2)))))) +//│ AST: TypingUnit(App(Var("+:"), Tup((N, IntLit(1)), (N, App(Var(":+"), Tup((N, App(Var("++"), Tup((N, StrLit(a)), (N, StrLit(b))))), (N, IntLit(2)))))))) //│ Parsed: +:(1, :+(++("a", "b",), 2,),); //│ [[Int], [["a", "b"], [Int]]] //│ res @@ -39,7 +39,7 @@ fun (++) conc(xs, ys) = [xs, ys] :p 1 +: "a" :+ 2 ++ "b" //│ |1| |+:| |"a"| |:+| |2| |++| |"b"| -//│ AST: TypingUnit(App(Var(+:), Tup(_: IntLit(1), _: App(Var(++), Tup(_: App(Var(:+), Tup(_: StrLit(a), _: IntLit(2))), _: StrLit(b)))))) +//│ AST: TypingUnit(App(Var("+:"), Tup((N, IntLit(1)), (N, App(Var("++"), Tup((N, App(Var(":+"), Tup((N, StrLit(a)), (N, IntLit(2))))), (N, StrLit(b)))))))) //│ Parsed: +:(1, ++(:+("a", 2,), "b",),); //│ [[Int], [["a", [Int]], "b"]] //│ res @@ -49,7 +49,7 @@ fun (++) conc(xs, ys) = [xs, ys] :e 1 +: "a" ++ 2 +: "b" //│ |1| |+:| |"a"| |++| |2| |+:| |"b"| -//│ AST: TypingUnit(App(Var(+:), Tup(_: IntLit(1), _: App(Var(+:), Tup(_: App(Var(++), Tup(_: StrLit(a), _: IntLit(2))), _: StrLit(b)))))) +//│ AST: TypingUnit(App(Var("+:"), Tup((N, IntLit(1)), (N, App(Var("+:"), Tup((N, App(Var("++"), Tup((N, StrLit(a)), (N, IntLit(2))))), (N, StrLit(b)))))))) //│ Parsed: +:(1, +:(++("a", 2,), "b",),); //│ ╔══[ERROR] Type mismatch in operator application: //│ ║ l.50: 1 +: "a" ++ 2 +: "b" diff --git a/shared/src/test/diff/nu/TODO_Classes.mls b/shared/src/test/diff/nu/TODO_Classes.mls index bc37f00a7..c3cef2e7f 100644 --- a/shared/src/test/diff/nu/TODO_Classes.mls +++ b/shared/src/test/diff/nu/TODO_Classes.mls @@ -80,7 +80,7 @@ new C { val x = 1 } //│ ╙── ^^^^^^^^^^^^^^^^^^^ //│ error //│ Code generation encountered an error: -//│ cannot generate code for term Rft(NuNew(Var(C)), ...) +//│ cannot generate code for term Rft(NuNew(Var("C")), TypingUnit(NuFunDef(Some(false), x, N, Nil, L(IntLit(1))))) diff --git a/shared/src/test/diff/ucs/LeadingAnd.mls b/shared/src/test/diff/ucs/LeadingAnd.mls index faa751e46..f1e65d9f1 100644 --- a/shared/src/test/diff/ucs/LeadingAnd.mls +++ b/shared/src/test/diff/ucs/LeadingAnd.mls @@ -23,7 +23,7 @@ fun f(a, b) = if a is Some(av) and b is Some(bv) then av + bv //│ |#fun| |f|(|a|,| |b|)| |#=| |#if| |a| |is| |Some|(|av|)|→|and| |b| |is| |Some|(|bv|)|↵|#then| |av| |+| |bv|←| -//│ AST: TypingUnit(NuFunDef(None, f, None, [], Lam(Tup(_: Var(a), _: Var(b)), If(IfOpApp(Var(a), Var(is), I; f; O; p; s; A; p; p; (; A; p; p; (; V; a; r; (; S; o; m; e; ); ,; ; T; u; p; (; _; :; ; V; a; r; (; a; v; ); ); ); ,; ; <; i; t; e; r; a; t; o; r; >, None)))) +//│ AST: TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("a")), (N, Var("b"))), If(IfOpApp(Var("a"), Var("is"), I; f; O; p; s; A; p; p; (; A; p; p; (; V; a; r; (; "; S; o; m; e; "; ); ,; ; T; u; p; (; (; N; ,; ; V; a; r; (; "; a; v; "; ); ); ); ); ,; ; <; i; t; e; r; a; t; o; r; >, None))))) //│ Parsed: fun f = (a, b,) => if a is Some(av,) ‹· and (is(b, Some(bv,),)) then +(av, bv,)›; //│ fun f: (Some[Int], Some[Int]) -> Int @@ -34,7 +34,7 @@ fun f(a, b) = if a is and b is Some(bv) then av + bv //│ |#fun| |f|(|a|,| |b|)| |#=| |#if| |a| |is|→|Some|(|av|)|→|and| |b| |is| |Some|(|bv|)|↵|#then| |av| |+| |bv|←|←| -//│ AST: TypingUnit(NuFunDef(None, f, None, [], Lam(Tup(_: Var(a), _: Var(b)), If(IfOpApp(Var(a), Var(is), IfBlock(I; f; O; p; s; A; p; p; (; A; p; p; (; V; a; r; (; S; o; m; e; ); ,; ; T; u; p; (; _; :; ; V; a; r; (; a; v; ); ); ); ,; ; <; i; t; e; r; a; t; o; r; >), None)))) +//│ AST: TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("a")), (N, Var("b"))), If(IfOpApp(Var("a"), Var("is"), IfBlock(Ls(I; f; O; p; s; A; p; p; (; A; p; p; (; V; a; r; (; "; S; o; m; e; "; ); ,; ; T; u; p; (; (; N; ,; ; V; a; r; (; "; a; v; "; ); ); ); ); ,; ; <; i; t; e; r; a; t; o; r; >)), None))))) //│ Parsed: fun f = (a, b,) => if a is ‹Some(av,) ‹· and (is(b, Some(bv,),)) then +(av, bv,)››; //│ ╔══[ERROR] Illegal pattern `and` //│ ║ l.34: and b is Some(bv) diff --git a/shared/src/test/diff/ucs/SplitOps.mls b/shared/src/test/diff/ucs/SplitOps.mls index 03ee227f5..70e9e0536 100644 --- a/shared/src/test/diff/ucs/SplitOps.mls +++ b/shared/src/test/diff/ucs/SplitOps.mls @@ -93,10 +93,10 @@ fun f(a, b, c) = if a == 0 and b is B() and c is C() then 0 //│ |#fun| |f|(|a|,| |b|,| |c|)| |#=|→|#if| |a|→|==| |0| |and| |b| |is| |B|(||)| |and| |c| |is| |C|(||)| |#then| |0|←|←| -//│ AST: TypingUnit(NuFunDef(None, f, None, [], Lam(Tup(_: Var(a), _: Var(b), _: Var(c)), Blk(...)))) +//│ AST: TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("a")), (N, Var("b")), (N, Var("c"))), Blk(If(I; f; O; p; s; A; p; p; (; V; a; r; (; "; a; "; ); ,; ; <; i; t; e; r; a; t; o; r; >, None)))))) //│ Parsed: fun f = (a, b, c,) => {if a ‹· == (and(and(0,)(is(b,)(B(),),),)(is(c,)(C(),),)) then 0›}; //│ Desugared: rec def f: (a, b, c,) => {if a ‹· == (and(and(0,)(is(b,)(B(),),),)(is(c,)(C(),),)) then 0›} -//│ AST: Def(true, f, Lam(Tup(_: Var(a), _: Var(b), _: Var(c)), Blk(...)), true) +//│ AST: Def(true, Var("f"), L(Lam(Tup((N, Var("a")), (N, Var("b")), (N, Var("c"))), Blk(If(I; f; O; p; s; A; p; p; (; V; a; r; (; "; a; "; ); ,; ; <; i; t; e; r; a; t; o; r; >, None)))), true) //│ ╔══[ERROR] The case when this is false is not handled: ==(a,)(0,) //│ ║ l.93: if a //│ ║ ^ diff --git a/shared/src/test/scala/mlscript/DiffTests.scala b/shared/src/test/scala/mlscript/DiffTests.scala index 2edc36dfc..91c9441f7 100644 --- a/shared/src/test/scala/mlscript/DiffTests.scala +++ b/shared/src/test/scala/mlscript/DiffTests.scala @@ -430,7 +430,7 @@ class DiffTests output("Parsed: " + res.showDbg) if (mode.showParse) - output("AST: " + mlscript.codegen.Helpers.inspect(res)) + output("AST: " + inspect.deep(res)) postProcess(mode, basePath, testName, res).foreach(output) @@ -622,7 +622,7 @@ class DiffTests typeDefs.foreach(td => output("Desugared: " + td)) stmts.foreach { s => output("Desugared: " + s) - output("AST: " + mlscript.codegen.Helpers.inspect(s)) + output("AST: " + inspect.deep(s)) } } From 3f4db0b6ebc19ab830f49b77b7f9322acd465878 Mon Sep 17 00:00:00 2001 From: Luyu Cheng Date: Sun, 31 Dec 2023 03:07:01 +0800 Subject: [PATCH 02/11] Fix a bug in `inspect` to keep the consistency in future commits --- compiler/shared/test/diff/LiftType.mls | 10 +++++----- compiler/shared/test/diff/Lifter.mls | 4 ++-- compiler/shared/test/diff/LifterBlks.mls | 4 ++-- shared/src/main/scala/mlscript/utils/inspect.scala | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/compiler/shared/test/diff/LiftType.mls b/compiler/shared/test/diff/LiftType.mls index f7a68e4d5..183dc1a6b 100644 --- a/compiler/shared/test/diff/LiftType.mls +++ b/compiler/shared/test/diff/LiftType.mls @@ -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(List((None,Field(None,Function(Tuple(List((None,Field(None,TypeName(A))))),TypeName(A)))))),TypeName(A))))))))) +//│ 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"))))))))) //│ Lifted: //│ TypingUnit { //│ class CTX$1_A$2([par$CTX$1,]) {} @@ -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(List((None,Field(None,TypeName(B))), (None,Field(None,TypeName(A)))))))))))) +//│ 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")))))))))) //│ Lifted: //│ TypingUnit { //│ class CTX$1_A$2([par$CTX$1,]) {fun foo = () => ((this).par$CTX$1).x} @@ -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(List((None,Field(None,TypeName(B))), (None,Field(None,TypeName(A)))))))))))) +//│ 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")))))))))) //│ Lifted: //│ TypingUnit { //│ class CTX$1_A$2([par$CTX$1,]) {fun foo = () => ((this).par$CTX$1).x} @@ -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(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)))))))))))) +//│ 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")))))))))) //│ Lifted: //│ TypingUnit { //│ class CTX$1_A$2([par$CTX$1,]) {fun foo = () => ((this).par$CTX$1).x} @@ -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(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)))))))))) //│ Lifted: //│ Lifting failed: mlscript.codegen.CodeGenError: Cannot find type T. Class values are not supported in lifter. //│ diff --git a/compiler/shared/test/diff/Lifter.mls b/compiler/shared/test/diff/Lifter.mls index 1486bb629..f074c30a5 100644 --- a/compiler/shared/test/diff/Lifter.mls +++ b/compiler/shared/test/diff/Lifter.mls @@ -125,7 +125,7 @@ class Parent(x) { //│ |#class| |Parent|‹|T|,| |U|,| |V|›|(|x|)| |{| |→|#fun| |foo|(|x|#:| |Int|)|#:| |T| |#=| |x|+|1|↵|#class| |Inner|‹|W|›|(|y|#:| |Int|)|{|→|#fun| |bar|(|z|#:| |U|)| |#=| |foo|(|y|)|↵|#fun| |boo|(|z|#:| |W|)| |#=| |z|←|↵|}|←|↵|}| //│ Parsed: {class Parent‹T, U, V›(x,) {fun foo = (x: Int,) => +(x, 1,) : T; class Inner‹W›(y: Int,) {fun bar = (z: U,) => foo(y,); fun boo = (z: W,) => z}}} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("Parent"), Ls(N -> TypeName("T"), N -> TypeName("U"), N -> TypeName("V")), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup((S(Var("x")), Var("Int"))), Asc(App(Var("+"), Tup((N, Var("x")), (N, IntLit(1)))), TypeName(T))))), NuTypeDef(Cls, TypeName("Inner"), Ls(N -> TypeName("W")), S(Tup((S(Var("y")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(Lam(Tup((S(Var("z")), Var("U"))), App(Var("foo"), Tup((N, Var("y"))))))), NuFunDef(None, boo, N, Nil, L(Lam(Tup((S(Var("z")), Var("W"))), Var("z"))))))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("Parent"), Ls(N -> TypeName("T"), N -> TypeName("U"), N -> TypeName("V")), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup((S(Var("x")), Var("Int"))), Asc(App(Var("+"), Tup((N, Var("x")), (N, IntLit(1)))), TypeName("T"))))), NuTypeDef(Cls, TypeName("Inner"), Ls(N -> TypeName("W")), S(Tup((S(Var("y")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(Lam(Tup((S(Var("z")), Var("U"))), App(Var("foo"), Tup((N, Var("y"))))))), NuFunDef(None, boo, N, Nil, L(Lam(Tup((S(Var("z")), Var("W"))), Var("z"))))))))) //│ Lifted: //│ TypingUnit { //│ class Parent$1_Inner$2[W,U]([par$Parent$1, y: Int,]) { @@ -213,7 +213,7 @@ new A(0) { //│ |#class| |A|(|x|#:| |Int|)| |{|→|#fun| |getA|#:| |Int| |#=| |0|↵|#fun| |getA1| |#=| |1|←|↵|}|↵|#new| |A|(|0|)| |{|→|#fun| |getA| |#=| |3|↵|#fun| |getA2| |#=| |2|←|↵|}| //│ Parsed: {class A(x: Int,) {fun getA = 0 : Int; fun getA1 = 1}; (new A)(0,) { ‹fun getA = 3; fun getA2 = 2› }} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((S(Var("x")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, getA, N, Nil, L(Asc(IntLit(0), TypeName(Int)))), NuFunDef(None, getA1, N, Nil, L(IntLit(1))))), Rft(App(NuNew(Var("A")), Tup((N, IntLit(0)))), TypingUnit(NuFunDef(None, getA, N, Nil, L(IntLit(3))), NuFunDef(None, getA2, N, Nil, L(IntLit(2)))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((S(Var("x")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, getA, N, Nil, L(Asc(IntLit(0), TypeName("Int")))), NuFunDef(None, getA1, N, Nil, L(IntLit(1))))), Rft(App(NuNew(Var("A")), Tup((N, IntLit(0)))), TypingUnit(NuFunDef(None, getA, N, Nil, L(IntLit(3))), NuFunDef(None, getA2, N, Nil, L(IntLit(2)))))) //│ Lifted: //│ TypingUnit { //│ class A$1([x: Int,]) {fun getA = () => 0 : Int; fun getA1 = () => 1} diff --git a/compiler/shared/test/diff/LifterBlks.mls b/compiler/shared/test/diff/LifterBlks.mls index 28ebd4467..b053241fd 100644 --- a/compiler/shared/test/diff/LifterBlks.mls +++ b/compiler/shared/test/diff/LifterBlks.mls @@ -19,7 +19,7 @@ class A{ //│ |#class| |A|{|→|#class| |B| |{||}|↵|#fun| |foo|(|x|#:| |B|)| |#=| |(|x| |#:| |B|)|←|↵|}| //│ Parsed: {class A {class B {}; fun foo = (x: B,) => '(' x : B ')'}} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit()), NuFunDef(None, foo, N, Nil, L(Lam(Tup((S(Var("x")), Var("B"))), Bra(rcd = false, Asc(Var("x"), TypeName(B))))))))) +//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit()), NuFunDef(None, foo, N, Nil, L(Lam(Tup((S(Var("x")), Var("B"))), Bra(rcd = false, Asc(Var("x"), TypeName("B"))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1,]) {} @@ -233,7 +233,7 @@ fun foo(x: T): string = //│ |#fun| |foo|‹|T|,| |U|›|(|x|#:| |T|)|#:| |string| |#=| |→|#class| |A|(|y|)| |#extends| |B|‹|T|›|,| |C|(|y|#:| |U|)| |{|→|#fun| |bar| |#=| |this|←|↵|}|↵|"rua"|←| //│ Parsed: {fun foo = (x: T,) => {class A(y,): B‹T›, C(y: U,) {fun bar = this}; "rua"} : string} //│ Parsed: -//│ TypingUnit(NuFunDef(None, foo, N, TypeName("T") :: TypeName("U") :: Nil, L(Lam(Tup((S(Var("x")), Var("T"))), Asc(Blk(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("y")))), N, N, Ls(TyApp(Var("B"), List(TypeName(T))), App(Var("C"), Tup((S(Var("y")), Var("U"))))), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(Var("this"))))), StrLit(rua)), TypeName(string)))))) +//│ TypingUnit(NuFunDef(None, foo, N, TypeName("T") :: TypeName("U") :: Nil, L(Lam(Tup((S(Var("x")), Var("T"))), Asc(Blk(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("y")))), N, N, Ls(TyApp(Var("B"), List(TypeName(T))), App(Var("C"), Tup((S(Var("y")), Var("U"))))), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(Var("this"))))), StrLit(rua)), TypeName("string")))))) //│ Lifted: //│ TypingUnit { //│ class A$1[T,U]([y,]): B‹T›, C(y: U,) {fun bar = () => this} diff --git a/shared/src/main/scala/mlscript/utils/inspect.scala b/shared/src/main/scala/mlscript/utils/inspect.scala index 3e4fa7d91..959cb2c62 100644 --- a/shared/src/main/scala/mlscript/utils/inspect.scala +++ b/shared/src/main/scala/mlscript/utils/inspect.scala @@ -64,7 +64,7 @@ object inspect { case Let(isRec, name, rhs, body) => s"Let($isRec, $name, ${apply(rhs)}, ${apply(body)})" case Blk(stmts) => s"Blk(${stmts.iterator.map(apply).mkString(", ")})" case Bra(rcd, trm) => s"Bra(rcd = $rcd, ${apply(trm)})" - case Asc(trm, ty) => s"Asc(${apply(trm)}, $ty)" + case Asc(trm, ty) => s"Asc(${apply(trm)}, ${apply(ty)})" case Bind(lhs, rhs) => s"Bind(${apply(lhs)}, ${apply(rhs)})" case Test(trm, ty) => s"Test(${apply(trm)}, ${apply(ty)})" case With(trm, fields) => From 460a5212f67d9bdd1b144c463f745a5aa9caa992 Mon Sep 17 00:00:00 2001 From: Luyu Cheng Date: Sun, 31 Dec 2023 03:08:51 +0800 Subject: [PATCH 03/11] Replace every `toString` call of all syntax nodes with `showDbg` I carefully created `showDbg` for many syntax nodes so that this commit does not change any test files. --- .../mlscript/compiler/PrettyPrinter.scala | 12 +- .../src/main/scala/mlscript/JSBackend.scala | 2 +- .../src/main/scala/mlscript/NuTypeDefs.scala | 2 +- shared/src/main/scala/mlscript/Typer.scala | 2 +- .../main/scala/mlscript/TyperDatatypes.scala | 2 +- shared/src/main/scala/mlscript/helpers.scala | 137 +++++++++--------- .../main/scala/mlscript/ucs/Desugarer.scala | 6 +- .../main/scala/mlscript/ucs/MutCaseOf.scala | 18 +-- .../main/scala/mlscript/ucs/Scrutinee.scala | 2 +- .../main/scala/mlscript/utils/inspect.scala | 10 +- .../src/test/scala/mlscript/DiffTests.scala | 16 +- 11 files changed, 108 insertions(+), 101 deletions(-) diff --git a/compiler/shared/main/scala/mlscript/compiler/PrettyPrinter.scala b/compiler/shared/main/scala/mlscript/compiler/PrettyPrinter.scala index 106748f96..14e91ccf4 100644 --- a/compiler/shared/main/scala/mlscript/compiler/PrettyPrinter.scala +++ b/compiler/shared/main/scala/mlscript/compiler/PrettyPrinter.scala @@ -5,7 +5,7 @@ import mlscript.compiler.debug.DebugOutput // For pretty printing terms in debug output. object PrettyPrinter: - def show(term: Term): DebugOutput = DebugOutput.Code(term.toString.linesIterator.toList) + def show(term: Term): DebugOutput = DebugOutput.Code(term.showDbg.linesIterator.toList) def show(unit: TypingUnit): DebugOutput = DebugOutput.Code(showTypingUnit(unit, 0).linesIterator.toList) def show(funDef: NuFunDef): DebugOutput = DebugOutput.Code(showFunDef(funDef).linesIterator.toList) def show(tyDef: NuTypeDef): DebugOutput = DebugOutput.Code(showTypeDef(tyDef, 0).linesIterator.toList) @@ -16,7 +16,7 @@ object PrettyPrinter: case term: Term => show(term) case tyDef: NuTypeDef => showTypeDef(tyDef) case funDef: NuFunDef => showFunDef(funDef) - case others => others.toString() + case others => others.showDbg }.mkString("{", "; ", "}") if (singleLine.length < 60) singleLine @@ -26,7 +26,7 @@ object PrettyPrinter: case term: Term => show(term) case tyDef: NuTypeDef => showTypeDef(tyDef) case funDef: NuFunDef => showFunDef(funDef) - case others => others.toString() + case others => others.showDbg }.map(indentStr + " " + _).mkString("{\n", "\n", s"\n$indentStr}") def showFunDef(funDef: NuFunDef): String = @@ -40,15 +40,15 @@ object PrettyPrinter: then "" else funDef.tparams.map(_.name).mkString("[", ", ", "]")) + " = " - + funDef.rhs.fold(_.toString, _.show(newDefs = true)) + + funDef.rhs.fold(_.showDbg, _.show(newDefs = true)) def showTypeDef(tyDef: NuTypeDef, indent: Int = 0): String = s"${tyDef.kind.str} ${tyDef.nme.name}" + (if tyDef.tparams.isEmpty then "" else tyDef.tparams.map(_._2.name).mkString("[", ",", "]")) - + tyDef.params.fold("")(params => s"($params)") + + tyDef.params.fold("")(params => s"(${params.showDbg})") + (if tyDef.parents.isEmpty then "" - else ": " + tyDef.parents.map(_.toString).mkString(", ")) + else ": " + tyDef.parents.map(_.showDbg).mkString(", ")) + showTypingUnit(tyDef.body, indent + 1) diff --git a/shared/src/main/scala/mlscript/JSBackend.scala b/shared/src/main/scala/mlscript/JSBackend.scala index d0ebaddeb..7068e96cb 100644 --- a/shared/src/main/scala/mlscript/JSBackend.scala +++ b/shared/src/main/scala/mlscript/JSBackend.scala @@ -368,7 +368,7 @@ abstract class JSBackend(allowUnresolvedSymbols: Bool) { } } case lit: Lit => - JSBinary("===", scrut, JSLit(lit.idStr)) + JSBinary("===", scrut, translateTerm(lit)) }, _, _ diff --git a/shared/src/main/scala/mlscript/NuTypeDefs.scala b/shared/src/main/scala/mlscript/NuTypeDefs.scala index 8eb2bdf2d..8d97dc000 100644 --- a/shared/src/main/scala/mlscript/NuTypeDefs.scala +++ b/shared/src/main/scala/mlscript/NuTypeDefs.scala @@ -560,7 +560,7 @@ class NuTypeDefs extends ConstraintSolver { self: Typer => case fd @ NuFunDef(_, nme, snme, tparams, R(rhs)) => funSigs.updateWith(nme.name) { case S(s) => - err(s"A type signature for '$nme' was already given", fd.toLoc) + err(s"A type signature for '${nme.name}' was already given", fd.toLoc) S(s) case N => S(fd) } diff --git a/shared/src/main/scala/mlscript/Typer.scala b/shared/src/main/scala/mlscript/Typer.scala index 1ba890989..3a3e5d15d 100644 --- a/shared/src/main/scala/mlscript/Typer.scala +++ b/shared/src/main/scala/mlscript/Typer.scala @@ -1380,7 +1380,7 @@ class Typer(var dbg: Boolean, var verbose: Bool, var explainErrors: Bool, val ne // () // and others case pat => - lastWords(s"Cannot handle pattern ${pat}") + lastWords(s"Cannot handle pattern ${pat.showDbg}") } handlePat(pat, cond_ty) diff --git a/shared/src/main/scala/mlscript/TyperDatatypes.scala b/shared/src/main/scala/mlscript/TyperDatatypes.scala index 121184b93..5fc80392a 100644 --- a/shared/src/main/scala/mlscript/TyperDatatypes.scala +++ b/shared/src/main/scala/mlscript/TyperDatatypes.scala @@ -240,7 +240,7 @@ abstract class TyperDatatypes extends TyperHelpers { Typer: Typer => RecordType(fields.filterNot(f => shadowing(f._1)) ++ fs)(prov) } def sorted: RecordType = RecordType(fields.sortBy(_._1))(prov) - override def toString = s"{${fields.map(f => s"${f._1}: ${f._2}").mkString(", ")}}" + override def toString = s"{${fields.map(f => s"${f._1.name}: ${f._2}").mkString(", ")}}" } object RecordType { def empty: RecordType = RecordType(Nil)(noProv) diff --git a/shared/src/main/scala/mlscript/helpers.scala b/shared/src/main/scala/mlscript/helpers.scala index cb069e47c..63de7f026 100644 --- a/shared/src/main/scala/mlscript/helpers.scala +++ b/shared/src/main/scala/mlscript/helpers.scala @@ -101,7 +101,7 @@ trait TypeLikeImpl extends Located { self: TypeLike => case AppliedType(n, args) => s"${n.name}${args.map(_.showIn(ctx, 0)).mkString(ctx.<, ", ", ctx.>)}" case Selection(b, n) => b.showIn(ctx, 100) + "." + n.name - case Rem(b, ns) => s"${b.showIn(ctx, 90)}${ns.map("\\"+_).mkString}" + case Rem(b, ns) => s"${b.showIn(ctx, 90)}${ns.map("\\"+_.name).mkString}" case Literal(IntLit(n)) => n.toString case Literal(DecLit(n)) => n.toString case Literal(StrLit(s)) => "\"" + s + "\"" @@ -173,7 +173,7 @@ trait TypeLikeImpl extends Located { self: TypeLike => case _ => "" }}${sig.fold("")(": " + _.showIn(bodyCtx, 0))}${parents match { case Nil => "" - case ps => " extends " + ps.mkString(", ") // TODO pp parent terms... + case ps => " extends " + ps.iterator.map(_.print(false)).mkString(", ") // TODO pp parent terms... }}${if (body.entities.isEmpty && sup.isEmpty && ths.isEmpty) "" else " {\n" + sup.fold("")(s"${bodyCtx.indStr}super: " + _.showIn(bodyCtx, 0) + "\n") + ths.fold("")(s"${bodyCtx.indStr}this: " + _.showIn(bodyCtx, 0) + "\n") + @@ -386,7 +386,8 @@ trait PgrmImpl { self: Pgrm => } diags.toList -> res } - override def toString = tops.map("" + _ + ";").mkString(" ") + + def showDbg: Str = tops.iterator.map("" + _.showDbg + ";").mkString(" ") } object OpApp { @@ -401,18 +402,18 @@ object OpApp { trait DeclImpl extends Located { self: Decl => val body: Located def showBody: Str = this match { - case Def(_, _, rhs, isByname) => rhs.fold(_.toString, _.showDbg2) + case Def(_, _, rhs, isByname) => rhs.fold(_.showDbg, _.showDbg2) case td: TypeDef => td.body.showDbg2 } def describe: Str = this match { case _: Def => "definition" case _: TypeDef => "type declaration" } - def showDbg: Str = showHead + (this match { + override def showDbg: Str = showHead + (this match { case TypeDef(Als, _, _, _, _, _, _, _) => " = "; case _ => ": " }) + showBody def showHead: Str = this match { - case Def(true, n, b, isByname) => s"rec def $n" - case Def(false, n, b, isByname) => s"def $n" + case Def(true, n, b, isByname) => s"rec def ${n.showDbg}" + case Def(false, n, b, isByname) => s"def ${n.showDbg}" case TypeDef(k, n, tps, b, _, _, pos, _) => s"${k.str} ${n.name}${if (tps.isEmpty) "" else tps.map(_.name).mkString("[", ", ", "]")}${ if (pos.isEmpty) "" else pos.mkString("(", ", ", ")") @@ -434,27 +435,27 @@ trait NuDeclImpl extends Located { self: NuDecl => } def name: Str = nameVar.name def showBody: Str = this match { - case NuFunDef(_, _, _, _, rhs) => rhs.fold(_.toString, _.showDbg2) - case td: NuTypeDef => td.body.showDbg + case NuFunDef(_, _, _, _, rhs) => rhs.fold(_.print(false), _.showDbg2) + case td: NuTypeDef => td.body.showDbgTop } def describe: Str = this match { case _: NuFunDef => "definition" case _: NuTypeDef => "type declaration" } - def showDbg: Str = showHead + (this match { + override def showDbg: Str = showHead + (this match { case NuFunDef(_, _, _, _, L(_)) => " = " case NuFunDef(_, _, _, _, R(_)) => ": " case _: NuTypeDef => " " }) + showBody def showHead: Str = this match { - case NuFunDef(N, n, snme, _, b) => s"fun${snme.fold("")(" ("+_+")")} $n" - case NuFunDef(S(false), n, snme, _, b) => s"let${snme.fold("")(" "+_+")")} $n" - case NuFunDef(S(true), n, snme, _, b) => s"let rec${snme.fold("")(" "+_+")")} $n" + case NuFunDef(N, n, snme, _, b) => s"fun${snme.fold("")(" ("+_.name+")")} ${n.name}" + case NuFunDef(S(false), n, snme, _, b) => s"let${snme.fold("")(" "+_.name+")")} ${n.name}" + case NuFunDef(S(true), n, snme, _, b) => s"let rec${snme.fold("")(" "+_.name+")")} ${n.name}" case NuTypeDef(k, n, tps, sps, ctor, sig, parents, sup, ths, bod) => s"${k.str} ${n.name}${if (tps.isEmpty) "" else tps.map(_._2.name).mkString("‹", ", ", "›")}${ sps.fold("")("(" + _.showElems + ")") }${sig.fold("")(": " + _.showDbg2)}${ - if (parents.isEmpty) "" else if (k === Als) " = " else ": "}${parents.mkString(", ")}" + if (parents.isEmpty) "" else if (k === Als) " = " else ": "}${parents.iterator.map(_.showDbg).mkString(", ")}" } lazy val genUnapply: Opt[NuFunDef] = this match { case td: NuTypeDef if td.kind is Cls => td.params.map { tup => @@ -472,13 +473,20 @@ trait NuDeclImpl extends Located { self: NuDecl => } trait TypingUnitImpl extends Located { self: TypingUnit => - def showDbg: Str = entities.map { - case t: Term => t.toString + def showDbg: Str = entities.iterator.map { + case t: Term => t.print(false) case d: NuDecl => d.showDbg - case c: Constructor => c.toString + case c: Constructor => c.showDbg + case e => lastWords(s"Unexpected typing unit entity: $e") + }.mkString("‹", "; ", "›") + + def showDbgTop: Str = entities.iterator.map { + case t: Term => t.print(false) + case d: NuDecl => d.showDbg + case c: Constructor => c.showDbg case e => lastWords(s"Unexpected typing unit entity: $e") }.mkString("{", "; ", "}") - override def toString: String = s"‹${entities.mkString("; ")}›" + lazy val children: List[Located] = entities } @@ -486,6 +494,7 @@ trait ConstructorImpl { self: Constructor => // def children: List[Located] = fields.map(_._2) def describe: Str = "constructor" // def showDbg: Str = s"constructor(${fields.map(_._1.name).mkString(", ")})" + override def showDbg: Str = s"constructor(${this.params.showElems}) ${this.body.showDbg}" } trait TypeNameImpl extends Ordered[TypeName] { self: TypeName => @@ -561,31 +570,31 @@ trait TermImpl extends StatementImpl { self: Term => case AdtMatchWith(cond, arms) => "ADT pattern matching" } } - - override def toString: Str = print(false) + + override def showDbg: Str = print(false) def print(brackets: Bool): Str = { def bra(str: Str): Str = if (brackets) s"($str)" else str this match { - case Bra(true, trm) => s"'{' $trm '}'" - case Bra(false, trm) => s"'(' $trm ')'" - case Blk(stmts) => stmts.mkString("{", "; ", "}") + case Bra(true, trm) => s"'{' ${trm.showDbg} '}'" + case Bra(false, trm) => s"'(' ${trm.showDbg} ')'" + case Blk(stmts) => stmts.iterator.map(_.showDbg).mkString("{", "; ", "}") case IntLit(value) => value.toString case DecLit(value) => value.toString case StrLit(value) => '"'.toString + value + '"' case UnitLit(value) => if (value) "undefined" else "null" case v @ Var(name) => name + v.uid.fold("")("::"+_.toString) - case Asc(trm, ty) => s"$trm : ${ty.showDbg2}" |> bra - case Lam(pat: Tup, rhs) => s"(${pat.showElems}) => $rhs" |> bra - case Lam(pat, rhs) => s"(...$pat) => $rhs" |> bra + case Asc(trm, ty) => s"${trm.showDbg} : ${ty.showDbg2}" |> bra + case Lam(pat: Tup, rhs) => s"(${pat.showElems}) => ${rhs.showDbg}" |> bra + case Lam(pat, rhs) => s"(...${pat.showDbg}) => ${rhs.showDbg}" |> bra case App(lhs, rhs: Tup) => s"${lhs.print(!lhs.isInstanceOf[App])}(${rhs.showElems})" |> bra case App(lhs, rhs) => s"${lhs.print(!lhs.isInstanceOf[App])}(...${rhs.print(true)})" |> bra case Rcd(fields) => fields.iterator.map(nv => - (if (nv._2.flags.mut) "mut " else "") + nv._1.name + ": " + nv._2.value).mkString("{", ", ", "}") - case Sel(receiver, fieldName) => "(" + receiver.toString + ")." + fieldName - case Let(isRec, name, rhs, body) => - s"let${if (isRec) " rec" else ""} $name = $rhs in $body" |> bra + (if (nv._2.flags.mut) "mut " else "") + nv._1.name + ": " + nv._2.value.showDbg).mkString("{", ", ", "}") + case Sel(receiver, fieldName) => "(" + receiver.showDbg + ")." + fieldName.showDbg + case Let(isRec, Var(name), rhs, body) => + s"let${if (isRec) " rec" else ""} $name = ${rhs.showDbg} in ${body.showDbg}" |> bra case tup: Tup => "[" + tup.showElems + "]" case Splc(fields) => fields.map{ case L(l) => s"...$l" @@ -596,26 +605,26 @@ trait TermImpl extends StatementImpl { self: Term => + r ) }.mkString("(", ", ", ")") - case Bind(l, r) => s"$l as $r" |> bra - case Test(l, r) => s"$l is $r" |> bra - case With(t, fs) => s"$t with $fs" |> bra + case Bind(l, r) => s"${l.showDbg} as ${r.showDbg}" |> bra + case Test(l, r) => s"${l.showDbg} is ${r.showDbg}" |> bra + case With(t, fs) => s"${t.showDbg} with ${fs.showDbg}" |> bra case CaseOf(s, c) => - s"case $s of { ${c.print(true)} }" |> bra - case Subs(a, i) => s"($a)[$i]" - case Assign(lhs, rhs) => s" $lhs <- $rhs" |> bra - case New(S((at, ar)), bod) => s"new ${at.showDbg2}($ar) ${bod.showDbg}" |> bra - case New(N, bod) => s"new ${bod.showDbg}" |> bra - case NuNew(cls) => s"new ${cls.print(false)}" |> bra - case If(body, els) => s"if $body" + els.fold("")(" else " + _) |> bra - case TyApp(lhs, targs) => s"$lhs‹${targs.map(_.showDbg2).mkString(", ")}›" - case Where(bod, wh) => s"${bod} where {${wh.mkString("; ")}}" - case Forall(ps, bod) => s"forall ${ps.mkString(", ")}. ${bod}" + s"case ${s.showDbg} of { ${c.print(true)} }" |> bra + case Subs(a, i) => s"(${a.showDbg})[${i.showDbg}]" + case Assign(lhs, rhs) => s" ${lhs.showDbg} <- ${rhs.showDbg}" |> bra + case New(S((at, ar)), bod) => s"new ${at.showDbg2}(${ar.showDbg}) ${bod.showDbgTop}" |> bra + case New(N, bod) => s"new ${bod.showDbgTop}" |> bra + case NuNew(cls) => s"new ${cls.showDbg}" |> bra + case If(body, els) => s"if ${body.showDbg}" + els.fold("")(" else " + _.showDbg) |> bra + case TyApp(lhs, targs) => s"${lhs.showDbg}‹${targs.iterator.map(_.showDbg2).mkString(", ")}›" + case Where(bod, wh) => s"${bod.showDbg} where {${wh.iterator.map(_.showDbg).mkString("; ")}}" + case Forall(ps, bod) => s"forall ${ps.mkString(", ")}. ${bod.showDbg}" case Inst(bod) => s"${bod.print(true)}!" case Super() => "super" - case Eqn(lhs, rhs) => s"${lhs} = ${rhs}" + case Eqn(lhs, rhs) => s"${lhs.showDbg} = ${rhs.showDbg}" case AdtMatchWith(cond, arms) => - s"match ${cond} with ${arms.map (patmat => s"${patmat.pat} -> ${patmat.rhs}").mkString (" | ") }" - case Rft(bse, tu) => s"${bse} { ${tu} }" + s"match ${cond.showDbg} with ${arms.map (patmat => s"${patmat.pat.showDbg} -> ${patmat.rhs.showDbg}").mkString (" | ") }" + case Rft(bse, tu) => s"${bse.showDbg} { ${tu.showDbg} }" }} def toTypeRaise(implicit raise: Raise): Type = toType match { @@ -739,7 +748,7 @@ trait TupImpl { self: Tup => (if (t.flags.mut) "mut " else "") + (if (t.flags.genGetter) "val " else "") + (if (t.flags.spec) "#" else "") - + n.fold("")(_.name + ": ") + t.value + "," + + n.fold("")(_.name + ": ") + t.value.print(false) + "," )}.mkString(" ") } @@ -747,7 +756,7 @@ trait SimpleTermImpl extends Ordered[SimpleTerm] { self: SimpleTerm => def compare(that: SimpleTerm): Int = this.idStr compare that.idStr val idStr: Str = this match { case Var(name) => name - case lit: Lit => lit.toString + case lit: Lit => lit.showDbg } } @@ -817,6 +826,8 @@ trait Located { trait DesugaredStatementImpl extends Located { self: DesugaredStatement => def describe: Str + + def showDbg: Str } trait StatementImpl extends Located { self: Statement => @@ -836,7 +847,7 @@ trait StatementImpl extends Located { self: Statement => case v @ Var(nme) => R(TypeName(nme).withLocOf(v)) case t => import Message._ - L(ErrorReport(msg"illegal datatype type parameter shape: ${t.toString}" -> t.toLoc :: Nil, newDefs=false)) + L(ErrorReport(msg"illegal datatype type parameter shape: ${t.showDbg}" -> t.toLoc :: Nil, newDefs=false)) } val (diags2, cs) = desugarCases(bod, targs) val dataDefs = cs.collect{case td: TypeDef => td} @@ -1000,15 +1011,11 @@ trait StatementImpl extends Located { self: Statement => case AdtMatchWith(cond, _) => cond :: Nil // FIXME discards branches... } - - override def toString: Str = this match { - case LetS(isRec, name, rhs) => s"let${if (isRec) " rec" else ""} $name = $rhs" - case DatatypeDefn(head, body) => s"data type $head of $body" - case DataDefn(head) => s"data $head" - case Constructor(params, bod) => s"constructor(${params.showElems}) $bod" - case _: Term => super.toString - case d: Decl => d.showDbg - case d: NuDecl => d.showDbg + def showDbg: Str = this match { + case LetS(isRec, name, rhs) => s"let${if (isRec) " rec" else ""} ${name.showDbg} = ${rhs.showDbg}" + case DatatypeDefn(head, body) => s"data type ${head.showDbg} of ${body.showDbg}" + case DataDefn(head) => s"data ${head.showDbg}" + case _: Constructor | _: Term | _: Decl | _: NuDecl => ??? // Implemented in subclasses } } @@ -1058,13 +1065,13 @@ trait IfBodyImpl extends Located { self: IfBody => case IfOpsApp(t, ops) => t :: ops.flatMap(x => x._1 :: x._2 :: Nil) } - override def toString: String = this match { - case IfThen(lhs, rhs) => s"($lhs) then $rhs" - case IfElse(trm) => s"else $trm" - case IfBlock(ts) => s"‹${ts.map(_.fold(identity, identity)).mkString("; ")}›" - case IfOpApp(lhs, op, ib) => s"$lhs $op $ib" - case IfOpsApp(lhs, ops) => s"$lhs ‹${ops.iterator.map{case(v, r) => s"· $v $r"}.mkString("; ")}›" - case IfLet(isRec, v, r, b) => s"${if (isRec) "rec " else ""}let $v = $r in $b" + def showDbg: String = this match { + case IfThen(lhs, rhs) => s"(${lhs.showDbg}) then ${rhs.showDbg}" + case IfElse(trm) => s"else ${trm.showDbg}" + case IfBlock(ts) => s"‹${ts.iterator.map(_.fold(_.showDbg, _.showDbg)).mkString("; ")}›" + case IfOpApp(lhs, op, ib) => s"${lhs.showDbg} ${op.showDbg} ${ib.showDbg}" + case IfOpsApp(lhs, ops) => s"${lhs.showDbg} ‹${ops.iterator.map{case(v, r) => s"· ${v.showDbg} ${r.showDbg}"}.mkString("; ")}›" + case IfLet(isRec, v, r, b) => s"${if (isRec) "rec " else ""}let ${v.showDbg} = ${r.showDbg} in ${b.showDbg}" } } diff --git a/shared/src/main/scala/mlscript/ucs/Desugarer.scala b/shared/src/main/scala/mlscript/ucs/Desugarer.scala index 6358f1892..6e49e61ef 100644 --- a/shared/src/main/scala/mlscript/ucs/Desugarer.scala +++ b/shared/src/main/scala/mlscript/ucs/Desugarer.scala @@ -379,7 +379,7 @@ class Desugarer extends TypeDefs { self: Typer => patternMap.foreachEntry { (pattern, locations) => val first = pattern match { case Left(tupleArity) => s"()^$tupleArity" - case Right(litOrCls) => litOrCls.toString() + case Right(litOrCls) => litOrCls.showDbg } val second = locations.mkString("[", ", ", "]") printlnUCS(s" + $first -> $second") @@ -689,7 +689,7 @@ class Desugarer extends TypeDefs { self: Typer => parentOpt match { case S(IfThenElse(test, whenTrue, whenFalse)) => if (whenFalse === t) - throw new DesugaringException(msg"The case when this is false is not handled: ${test.toString}", test.toLoc) + throw new DesugaringException(msg"The case when this is false is not handled: ${test.showDbg}", test.toLoc) else lastWords("`MissingCase` are not supposed to be the true branch of `IfThenElse`") case S(Match(_, _, _)) => @@ -755,7 +755,7 @@ class Desugarer extends TypeDefs { self: Typer => missingCases.iterator.zipWithIndex.flatMap { case ((pattern, locations), index) => val patternName = pattern match { case L(tupleArity) => s"$tupleArity-ary tuple" - case R(litOrCls) => litOrCls.toString() + case R(litOrCls) => litOrCls.showDbg } val progress = s"[Missing Case ${index + 1}/$numMissingCases]" (msg"$progress `$patternName`" -> N) :: diff --git a/shared/src/main/scala/mlscript/ucs/MutCaseOf.scala b/shared/src/main/scala/mlscript/ucs/MutCaseOf.scala index 199d5619a..8472e8b31 100644 --- a/shared/src/main/scala/mlscript/ucs/MutCaseOf.scala +++ b/shared/src/main/scala/mlscript/ucs/MutCaseOf.scala @@ -62,7 +62,7 @@ sealed abstract class MutCaseOf extends WithBindings { object MutCaseOf { def showScrutinee(scrutinee: Scrutinee): Str = - s"«${scrutinee.term}»" + (scrutinee.local match { + s"«${scrutinee.term.showDbg}»" + (scrutinee.local match { case N => "" case S(Var(alias)) => s" as $alias" }) @@ -72,15 +72,15 @@ object MutCaseOf { def rec(t: MutCaseOf, indent: Int): Unit = { val baseIndent = " " * indent lazy val bindingLines = t.getBindings.iterator.map { - case LetBinding(_, recursive, name, term) => + case LetBinding(_, recursive, Var(name), term) => // Show bindings - s"[binding $name = $term]" + s"[binding $name = ${term.showDbg}]" }.toList t match { case IfThenElse(condition, whenTrue, whenFalse) => // Output the `whenTrue` with the prefix "if". bindingLines.foreach { lines += baseIndent + _ } - lines += baseIndent + s"if «$condition»" + lines += baseIndent + s"if «${condition.showDbg}»" rec(whenTrue, indent + 1) // Output the `whenFalse` case with the prefix "else". lines += s"${baseIndent}else" @@ -90,13 +90,13 @@ object MutCaseOf { lines += baseIndent + showScrutinee(scrutinee) + " match" branches.foreach { case MutCase.Literal(literal, consequent) => - lines += s"$baseIndent case $literal =>" + lines += s"$baseIndent case ${literal.showDbg} =>" rec(consequent, indent + 1) case MutCase.Constructor(Var(className) -> fields, consequent) => lines += s"$baseIndent case $className =>" fields.foreach { case (field, Var(alias)) => // Show pattern bindings. - lines += s"$baseIndent [pattern $alias = ${scrutinee.reference}.$field]" + lines += s"$baseIndent [pattern $alias = ${scrutinee.reference.showDbg}.$field]" } rec(consequent, indent + 2) } @@ -106,7 +106,7 @@ object MutCaseOf { } case Consequent(term) => bindingLines.foreach { lines += baseIndent + _ } - lines += s"$baseIndent«$term»" + lines += s"$baseIndent«${term.showDbg}»" case MissingCase => bindingLines.foreach { lines += baseIndent + _ } lines += s"$baseIndent" @@ -210,7 +210,7 @@ object MutCaseOf { // A short-hand for pattern matchings with only true and false branches. final case class IfThenElse(condition: Term, var whenTrue: MutCaseOf, var whenFalse: MutCaseOf) extends MutCaseOf { def describe: Str = - s"IfThenElse($condition, whenTrue = ${whenTrue.kind}, whenFalse = ${whenFalse.kind})" + s"IfThenElse(${condition.showDbg}, whenTrue = ${whenTrue.kind}, whenFalse = ${whenFalse.kind})" def duplicate(): MutCaseOf = IfThenElse(condition, whenTrue.duplicate(), whenFalse.duplicate()) @@ -469,7 +469,7 @@ object MutCaseOf { } } final case class Consequent(term: Term) extends MutCaseOf { - def describe: Str = s"Consequent($term)" + def describe: Str = s"Consequent(${term.showDbg})" override def fill(subTree: MutCaseOf): Unit = () diff --git a/shared/src/main/scala/mlscript/ucs/Scrutinee.scala b/shared/src/main/scala/mlscript/ucs/Scrutinee.scala index a0ce56d3e..899c5629a 100644 --- a/shared/src/main/scala/mlscript/ucs/Scrutinee.scala +++ b/shared/src/main/scala/mlscript/ucs/Scrutinee.scala @@ -26,5 +26,5 @@ final case class Scrutinee(var local: Opt[Var], term: Term)(val matchRootLoc: Op (local match { case N => "" case S(Var(alias)) => s"$alias @ " - }) + s"$term" + }) + s"${term.showDbg}" } diff --git a/shared/src/main/scala/mlscript/utils/inspect.scala b/shared/src/main/scala/mlscript/utils/inspect.scala index 959cb2c62..819a62ce7 100644 --- a/shared/src/main/scala/mlscript/utils/inspect.scala +++ b/shared/src/main/scala/mlscript/utils/inspect.scala @@ -60,8 +60,8 @@ object inspect { }.mkString("Tup(", ", ", ")") case Rcd(fields) => fields.iterator.map { case k -> Fld(_, v) => s"${apply(k)} = ${apply(v)}" }.mkString("Rcd(", ", ", ")") - case Sel(receiver, fieldName) => s"Sel(${apply(receiver)}, $fieldName)" - case Let(isRec, name, rhs, body) => s"Let($isRec, $name, ${apply(rhs)}, ${apply(body)})" + case Sel(receiver, fieldName) => s"Sel(${apply(receiver)}, ${fieldName.name})" + case Let(isRec, name, rhs, body) => s"Let($isRec, ${name.name}, ${apply(rhs)}, ${apply(body)})" case Blk(stmts) => s"Blk(${stmts.iterator.map(apply).mkString(", ")})" case Bra(rcd, trm) => s"Bra(rcd = $rcd, ${apply(trm)})" case Asc(trm, ty) => s"Asc(${apply(trm)}, ${apply(ty)})" @@ -126,10 +126,10 @@ object inspect { case Union(lhs, rhs) => s"Union(${apply(lhs)}, ${apply(rhs)})" case Inter(lhs, rhs) => s"Inter(${apply(lhs)}, ${apply(rhs)})" case Function(lhs, rhs) => s"Function(${apply(lhs)}, ${apply(rhs)})" - case Record(fields) => s"Record(${fields.iterator.map { case (nme, ty) => s"$nme: ${apply(ty)}" }.mkString(", ")})" + case Record(fields) => s"Record(${fields.iterator.map { case (nme, ty) => s"${nme.name}: ${apply(ty)}" }.mkString(", ")})" case Tuple(fields) => s"Tuple(${fields.iterator.map { case N -> field => s"N -> ${apply(field)}" - case S(nme) -> field => s"S($nme) -> ${apply(field)}" + case S(Var(name)) -> field => s"S($name) -> ${apply(field)}" }.mkString(", ")})" case Recursive(uv, body) => s"Recursive(${apply(uv)}, ${apply(body)})" case AppliedType(base, targs) => s"AppliedType(${apply(base)}, ${apply(targs)})" @@ -147,7 +147,7 @@ object inspect { }}), ${apply(where)})" case Top => "Top" case Bot => "Bot" - case Literal(lit) => s"Literal(${lit.toString})" + case Literal(lit) => s"Literal(${lit.showDbg})" case TypeName(name) => s"TypeName(\"$name\")" case TypeTag(name) => s"TypeTag($name)" case TypeVar(identifier, nameHint) => s"TypeVar(${identifier match { diff --git a/shared/src/test/scala/mlscript/DiffTests.scala b/shared/src/test/scala/mlscript/DiffTests.scala index 91c9441f7..a1c7b721a 100644 --- a/shared/src/test/scala/mlscript/DiffTests.scala +++ b/shared/src/test/scala/mlscript/DiffTests.scala @@ -427,7 +427,7 @@ class DiffTests val res = p.parseAll(p.typingUnit) if (parseOnly) - output("Parsed: " + res.showDbg) + output("Parsed: " + res.showDbgTop) if (mode.showParse) output("AST: " + inspect.deep(res)) @@ -459,7 +459,7 @@ class DiffTests case Success(p, index) => if (mode.expectParseErrors && !newParser) failures += blockLineNum - if (mode.showParse || mode.dbgParsing) output("Parsed: " + p) + if (mode.showParse || mode.dbgParsing) output("Parsed: " + p.showDbg) // if (mode.isDebugging) typer.resetState() if (mode.stats) typer.resetStats() typer.dbg = mode.dbg @@ -619,9 +619,9 @@ class DiffTests report(diags) if (mode.showParse) { - typeDefs.foreach(td => output("Desugared: " + td)) + typeDefs.foreach(td => output("Desugared: " + td.showDbg)) stmts.foreach { s => - output("Desugared: " + s) + output("Desugared: " + s.showDbg) output("AST: " + inspect.deep(s)) } } @@ -769,7 +769,7 @@ class DiffTests declared += nme.name -> ty_sch val exp = getType(ty_sch, N) if (mode.generateTsDeclarations) tsTypegenCodeBuilder.addTypeGenTermDefinition(exp, Some(nme.name)) - S(nme.name -> (s"$nme: ${exp.show(newDefs)}" :: Nil)) + S(nme.name -> (s"${nme.name}: ${exp.show(newDefs)}" :: Nil)) // statement is defined and has a body/definition case d @ Def(isrec, nme, L(rhs), isByname) => @@ -784,7 +784,7 @@ class DiffTests case N => ctx += nme.name -> typer.VarSymbol(ty_sch, nme) if (mode.generateTsDeclarations) tsTypegenCodeBuilder.addTypeGenTermDefinition(exp, Some(nme.name)) - s"$nme: ${exp.show(newDefs)}" :: Nil + s"${nme.name}: ${exp.show(newDefs)}" :: Nil // statement has a body and a declared type // both are used to compute a subsumption (What is this??) @@ -796,7 +796,7 @@ class DiffTests typer.subsume(ty_sch, sign)(ctx, raiseToBuffer, typer.TypeProvenance(d.toLoc, "def definition")) if (mode.generateTsDeclarations) tsTypegenCodeBuilder.addTypeGenTermDefinition(exp, Some(nme.name)) typeBeforeDiags = true - exp.show(newDefs) :: s" <: $nme:" :: sign_exp.show(newDefs) :: Nil + exp.show(newDefs) :: s" <: ${nme.name}:" :: sign_exp.show(newDefs) :: Nil })) case desug: DesugaredStatement => typer.dbg = mode.dbg @@ -1051,7 +1051,7 @@ class DiffTests err.getStackTrace().take( if (mode.fullExceptionStack) Int.MaxValue else if (mode.fixme || err.isInstanceOf[StackOverflowError]) 0 - else 10 + else 50 ).map("\n" + "\tat: " + _).mkString) } finally { typer.dbg = false From dcef2e26c648c171fd2071c57b3e04d27ee7ee93 Mon Sep 17 00:00:00 2001 From: Luyu Cheng Date: Sun, 31 Dec 2023 03:18:08 +0800 Subject: [PATCH 04/11] Remove `inspect` function and replace all its calls with `toString` --- .../scala/mlscript/compiler/ClassLifter.scala | 3 +- .../scala/mlscript/compiler/Helpers.scala | 3 +- .../test/scala/mlscript/compiler/Test.scala | 3 +- .../src/main/scala/mlscript/JSBackend.scala | 10 +- .../main/scala/mlscript/utils/inspect.scala | 182 ------------------ shared/src/test/diff/basics/Blocks.fun | 10 +- shared/src/test/diff/basics/Data.fun | 4 +- shared/src/test/diff/basics/Datatypes.fun | 14 +- shared/src/test/diff/basics/Either.fun | 4 +- shared/src/test/diff/basics/Flow.fun | 4 +- shared/src/test/diff/basics/Operators.fun | 16 +- shared/src/test/diff/basics/Slashes.fun | 2 +- shared/src/test/diff/mlscript/Basics.mls | 2 +- .../src/test/diff/mlscript/ByNameByValue.mls | 4 +- shared/src/test/diff/mlscript/MultiArgs.mls | 8 +- shared/src/test/diff/mlscript/Mut.mls | 2 +- shared/src/test/diff/mlscript/Ops.mls | 10 +- shared/src/test/diff/mlscript/Weird.mls | 4 +- shared/src/test/diff/nu/AbstractClasses.mls | 2 +- shared/src/test/diff/nu/BadBlocks.mls | 2 +- shared/src/test/diff/nu/LamPatterns.mls | 2 +- shared/src/test/diff/nu/LetRec.mls | 2 +- shared/src/test/diff/nu/NewNew.mls | 12 +- shared/src/test/diff/nu/OpLam.mls | 2 +- shared/src/test/diff/nu/OverrideShorthand.mls | 4 +- shared/src/test/diff/nu/Refinements.mls | 2 +- shared/src/test/diff/nu/RightAssocOps.mls | 6 +- shared/src/test/diff/nu/TODO_Classes.mls | 2 +- shared/src/test/diff/ucs/LeadingAnd.mls | 4 +- shared/src/test/diff/ucs/SplitOps.mls | 4 +- .../src/test/scala/mlscript/DiffTests.scala | 4 +- 31 files changed, 74 insertions(+), 259 deletions(-) delete mode 100644 shared/src/main/scala/mlscript/utils/inspect.scala diff --git a/compiler/shared/main/scala/mlscript/compiler/ClassLifter.scala b/compiler/shared/main/scala/mlscript/compiler/ClassLifter.scala index 947db768a..559bc5957 100644 --- a/compiler/shared/main/scala/mlscript/compiler/ClassLifter.scala +++ b/compiler/shared/main/scala/mlscript/compiler/ClassLifter.scala @@ -7,7 +7,6 @@ import scala.collection.mutable.StringBuilder as StringBuilder import scala.collection.mutable.Map as MutMap import scala.collection.mutable.Set as MutSet import scala.collection.mutable.ArrayBuffer as ArrayBuffer -import inspect.deep as showStructure import mlscript.codegen.CodeGenError import mlscript.compiler.mono.MonomorphError @@ -748,7 +747,7 @@ class ClassLifter(logDebugMsg: Boolean = false) { def liftTypingUnit(rawUnit: TypingUnit): TypingUnit = { log("=========================\n") - log(s"lifting: \n${showStructure(rawUnit)}\n") + log(s"lifting: \n$rawUnit\n") retSeq = Nil globalFunctions.clear() val re = liftEntities(rawUnit.entities)(using emptyCtx, Map(), Map(), None) diff --git a/compiler/shared/main/scala/mlscript/compiler/Helpers.scala b/compiler/shared/main/scala/mlscript/compiler/Helpers.scala index ed842b704..41515a772 100644 --- a/compiler/shared/main/scala/mlscript/compiler/Helpers.scala +++ b/compiler/shared/main/scala/mlscript/compiler/Helpers.scala @@ -1,7 +1,6 @@ package mlscript package compiler -import mlscript.utils.inspect.deep as showStructure import mlscript.compiler.mono.{Monomorph, MonomorphError} import scala.collection.mutable.ArrayBuffer @@ -16,7 +15,7 @@ object Helpers: case (None, Fld(FldFlags(_, spec, _), Var(name))) => Some((spec, Expr.Ref(name))) case (Some(Var(name)), Fld(FldFlags(_, spec, _), _)) => Some((spec, Expr.Ref(name))) case _ => throw new MonomorphError( - s"only `Var` can be parameters but we meet ${showStructure(term)}" + s"only `Var` can be parameters but we meet $term" ) } case _ => throw MonomorphError("expect the list of parameters to be a `Tup`") diff --git a/compiler/shared/test/scala/mlscript/compiler/Test.scala b/compiler/shared/test/scala/mlscript/compiler/Test.scala index 2e2349bf6..a93ca5089 100644 --- a/compiler/shared/test/scala/mlscript/compiler/Test.scala +++ b/compiler/shared/test/scala/mlscript/compiler/Test.scala @@ -3,7 +3,6 @@ package mlscript.compiler import mlscript.utils.shorthands.* import scala.util.control.NonFatal import scala.collection.mutable.StringBuilder -import mlscript.utils.inspect.deep as showStructure import mlscript.{DiffTests, ModeType, TypingUnit} import mlscript.compiler.debug.TreeDebug import mlscript.compiler.mono.Monomorph @@ -15,7 +14,7 @@ class DiffTestCompiler extends DiffTests { override def postProcess(mode: ModeType, basePath: List[Str], testName: Str, unit: TypingUnit): List[Str] = val outputBuilder = StringBuilder() outputBuilder ++= "Parsed:\n" - outputBuilder ++= showStructure(unit) + outputBuilder ++= unit.toString outputBuilder ++= "\nLifted:\n" var rstUnit = unit; diff --git a/shared/src/main/scala/mlscript/JSBackend.scala b/shared/src/main/scala/mlscript/JSBackend.scala index 7068e96cb..d745e8f3c 100644 --- a/shared/src/main/scala/mlscript/JSBackend.scala +++ b/shared/src/main/scala/mlscript/JSBackend.scala @@ -68,7 +68,7 @@ abstract class JSBackend(allowUnresolvedSymbols: Bool) { case Inst(bod) => translatePattern(bod) case _: Lam | _: App | _: Sel | _: Let | _: Blk | _: Bind | _: Test | _: With | _: CaseOf | _: Subs | _: Assign | If(_, _) | New(_, _) | NuNew(_) | _: Splc | _: Forall | _: Where | _: Super | _: Eqn | _: AdtMatchWith | _: Rft => - throw CodeGenError(s"term ${inspect.deep(t)} is not a valid pattern") + throw CodeGenError(s"term $t is not a valid pattern") } private def translateParams(t: Term)(implicit scope: Scope): Ls[JSPattern] = t match { @@ -171,7 +171,7 @@ abstract class JSBackend(allowUnresolvedSymbols: Bool) { } callee(args map { case (_, Fld(_, arg)) => translateTerm(arg) }: _*) case App(trm, splice) => ??? // TODO represents `trm(...splice)` - case _ => throw CodeGenError(s"ill-formed application ${inspect.deep(term)}") + case _ => throw CodeGenError(s"ill-formed application $term") } /** @@ -296,7 +296,7 @@ abstract class JSBackend(allowUnresolvedSymbols: Bool) { case _: Subs | _: Sel | _: Var => JSCommaExpr(JSAssignExpr(translateTerm(lhs), translateTerm(value)) :: JSArray(Nil) :: Nil) case _ => - throw CodeGenError(s"illegal assignemnt left-hand side: ${inspect.deep(lhs)}") + throw CodeGenError(s"illegal assignemnt left-hand side: $lhs") } case Inst(bod) => translateTerm(bod) case iff: If => @@ -309,7 +309,7 @@ abstract class JSBackend(allowUnresolvedSymbols: Bool) { case n: JSNew => n case t => JSNew(t) } - case _ => throw CodeGenError(s"Unsupported `new` class term: ${inspect.deep(cls)}") + case _ => throw CodeGenError(s"Unsupported `new` class term: $cls") } // * Would not be quite correct: // JSNew(translateTerm(cls)) @@ -327,7 +327,7 @@ abstract class JSBackend(allowUnresolvedSymbols: Bool) { case Eqn(Var(name), _) => throw CodeGenError(s"assignment of $name is not supported outside a constructor") case _: Bind | _: Test | If(_, _) | _: Splc | _: Where | _: AdtMatchWith | _: Rft => - throw CodeGenError(s"cannot generate code for term ${inspect.deep(term)}") + throw CodeGenError(s"cannot generate code for term $term") } private def translateCaseBranch(scrut: JSExpr, branch: CaseBranches)(implicit diff --git a/shared/src/main/scala/mlscript/utils/inspect.scala b/shared/src/main/scala/mlscript/utils/inspect.scala deleted file mode 100644 index 819a62ce7..000000000 --- a/shared/src/main/scala/mlscript/utils/inspect.scala +++ /dev/null @@ -1,182 +0,0 @@ -package mlscript.utils - -import mlscript._, shorthands._ - -object inspect { - object shallow { - def apply(term: Statement): Str = term match { - case Var(name) => s"Var(\"$name\")" - case literal: Lit => s"Lit(${literal.toString})" - case fd: NuFunDef => fd.isLetRec.fold("fun")(if (_) "let rec" else "let") + " " + fd.nme.name - case td: NuTypeDef => s"${td.kind.str} ${td.nme.name}" - case _ => - val name = term.getClass.getSimpleName - val arity = term.children.length // Imprecise - if (arity === 0) { name } else s"${name}(${(", _" * arity).drop(2)})" - } - - def apply(d: TypingUnit): Str = d.entities.iterator - .map(apply) - .mkString("{", ", ", "}") - } - - object deep { - def apply(t: Opt[Located]): Str = t match { - case N => "N" - case S(l) => s"S(${apply(l)})" - } - - def apply(t: Ls[Located]): Str = t match { - case Nil => "Nil" - case head :: Nil => s"${apply(head)} :: Nil" - case first :: second :: Nil => s"${apply(first)} :: ${apply(second)} :: Nil" - case _ => t.iterator.map(apply).mkString("Ls(", ", ", ")") - } - - def apply[A <: Located, B <: Located](t: Either[A, B]): Str = t match { - case L(value) => s"L(${apply(value)})" - case R(value) => s"R(${apply(value)})" - } - - def apply(t: Located): Str = t match { - case st: Statement => statement(st) - case fl: Field => field(fl) - case ty: TypeLike => typeLike(ty) - case ib: IfBody => ifBody(ib) - case tu: TypingUnit => typingUnit(tu) - case _ => "??" - } - - private def statement(statement: Statement): Str = statement match { - case Def(rec, nme, rhs, isByname) => s"Def($rec, ${apply(nme)}, ${apply(rhs)}, $isByname)" - case TypeDef(kind, nme, tparams, body, mthDecls, mthDefs, positionals, adtInfo) => s"TypeDef(...)" - case Var(name) => s"Var(\"$name\")" - case Lam(lhs, rhs) => s"Lam(${apply(lhs)}, ${apply(rhs)})" - case App(lhs, rhs) => s"App(${apply(lhs)}, ${apply(rhs)})" - case Tup(fields) => - fields.iterator.map { - case (S(name), Fld(_, value)) => s"(S(${apply(name)}), ${apply(value)})" - case (N, Fld(_, value)) => s"(N, ${apply(value)})" - }.mkString("Tup(", ", ", ")") - case Rcd(fields) => - fields.iterator.map { case k -> Fld(_, v) => s"${apply(k)} = ${apply(v)}" }.mkString("Rcd(", ", ", ")") - case Sel(receiver, fieldName) => s"Sel(${apply(receiver)}, ${fieldName.name})" - case Let(isRec, name, rhs, body) => s"Let($isRec, ${name.name}, ${apply(rhs)}, ${apply(body)})" - case Blk(stmts) => s"Blk(${stmts.iterator.map(apply).mkString(", ")})" - case Bra(rcd, trm) => s"Bra(rcd = $rcd, ${apply(trm)})" - case Asc(trm, ty) => s"Asc(${apply(trm)}, ${apply(ty)})" - case Bind(lhs, rhs) => s"Bind(${apply(lhs)}, ${apply(rhs)})" - case Test(trm, ty) => s"Test(${apply(trm)}, ${apply(ty)})" - case With(trm, fields) => - s"With(${apply(trm)}, ${apply(fields)})" - case CaseOf(trm, cases) => - def inspectCaseBranches(br: CaseBranches): Str = br match { - case Case(clsNme, body, rest) => - s"Case($clsNme, ${apply(body)}, ${inspectCaseBranches(rest)})" - case Wildcard(body) => s"Wildcard(${apply(body)})" - case NoCases => "NoCases" - } - s"CaseOf(${apply(trm)}, ${inspectCaseBranches(cases)}" - case IntLit(value) => s"IntLit($value)" - case DecLit(value) => s"DecLit($value)" - case StrLit(value) => s"StrLit($value)" - case UnitLit(value) => s"UnitLit($value)" - case Subs(arr, idx) => s"Subs(${apply(arr)}, ${apply(idx)})" - case Assign(f, v) => s"Assign(${apply(f)}, ${apply(v)})" - case Splc(fs) => - fs.iterator.map{ case L(l) => s"...${apply(l)}" case R(Fld(_, r)) => apply(r)}.mkString("Splc(", ", ", ")") - case If(bod, els) => s"If(${apply(bod)}, ${els.map(apply)})" - case New(base, body) => s"New(${base}, ${apply(body)})" - case NuNew(base) => s"NuNew(${apply(base)})" - case TyApp(base, targs) => s"TyApp(${apply(base)}, ${targs})" - case Where(bod, sts) => s"Where(${apply(bod)}, ...)" - case Forall(ps, bod) => s"Forall($ps, ${apply(bod)})" - case Inst(bod) => s"Inst(${apply(bod)})" - case Eqn(lhs, rhs) => s"Eqn(${apply(lhs)}, ${apply(rhs)})" - case Super() => "Super()" - case AdtMatchWith(cond, arms) => - s"match ${apply(cond)} with ${arms.map(patmat => s"${apply(patmat.pat)} -> ${apply(patmat.rhs)}").mkString(" | ")}" - case Rft(bse, tu) => s"Rft(${apply(bse)}, ${apply(tu)})" - case LetS(isRec, pat, rhs) => s"LetS($isRec, ${apply(pat)}, ${apply(rhs)})" - case DataDefn(body) => s"DataDefn(${apply(body)})" - case DatatypeDefn(head, body) => s"DatatypeDefn(${apply(head)}, ${apply(body)})" - case NuTypeDef(kind, nme, tparams, params, ctor, sig, parents, superAnnot, thisAnnot, body) => - s"NuTypeDef($kind, ${apply(nme)}, Ls(" + - tparams.iterator.map { - case (S(vi), tn) => s"S($vi) -> ${apply(tn)}" - case (N, tn) => s"N -> ${apply(tn)}" - }.mkString(", ") + "), " + - apply(params) + ", " + - apply(ctor) + ", " + - apply(sig) + ", " + - parents.iterator.map(apply).mkString("Ls(", ", ", ")") + ", " + - apply(superAnnot) + ", " + - apply(thisAnnot) + ", " + - apply(body) + ")" - case NuFunDef(isLetRec, nme, symbolicNme, tparams, rhs) => - s"NuFunDef($isLetRec, ${nme.name}, ${apply(symbolicNme)}, ${apply(tparams)}, ${apply(rhs)})" - case Constructor(params, body) => s"Constructor" - } - - private def field(field: Field): Str = field match { - case Field(nme, value) => s"Fld(${apply(nme)}, ${apply(value)})" - } - - private def typeLike(ty: TypeLike): Str = ty match { - case Union(lhs, rhs) => s"Union(${apply(lhs)}, ${apply(rhs)})" - case Inter(lhs, rhs) => s"Inter(${apply(lhs)}, ${apply(rhs)})" - case Function(lhs, rhs) => s"Function(${apply(lhs)}, ${apply(rhs)})" - case Record(fields) => s"Record(${fields.iterator.map { case (nme, ty) => s"${nme.name}: ${apply(ty)}" }.mkString(", ")})" - case Tuple(fields) => s"Tuple(${fields.iterator.map { - case N -> field => s"N -> ${apply(field)}" - case S(Var(name)) -> field => s"S($name) -> ${apply(field)}" - }.mkString(", ")})" - case Recursive(uv, body) => s"Recursive(${apply(uv)}, ${apply(body)})" - case AppliedType(base, targs) => s"AppliedType(${apply(base)}, ${apply(targs)})" - case Selection(base, name) => s"Selection(${apply(base)}, $name)" - case Neg(base) => s"Neg(${apply(base)})" - case Rem(base, names) => s"Rem(${apply(base)}, ${names.iterator.map(apply).mkString(", ")})" - case Bounds(lb, ub) => s"Bounds(${apply(lb)}, ${apply(ub)})" - case WithExtension(base, rcd) => s"WithExtension(${apply(base)}, ${apply(rcd)})" - case Splice(fields) => s"Splice(${fields.iterator.map { - case L(l) => s"L(${apply(l)})" - case R(f) => s"R(${apply(f)})" - }.mkString(", ")})" - case Constrained(base, tvBounds, where) => s"Constrained(${apply(base)}, Ls(${tvBounds.iterator.map { - case (tv, bounds) => s"${apply(tv)} -> ${apply(bounds)}" - }}), ${apply(where)})" - case Top => "Top" - case Bot => "Bot" - case Literal(lit) => s"Literal(${lit.showDbg})" - case TypeName(name) => s"TypeName(\"$name\")" - case TypeTag(name) => s"TypeTag($name)" - case TypeVar(identifier, nameHint) => s"TypeVar(${identifier match { - case L(i) => s"L($i)" - case R(n) => s"R($n)" - }}, ${nameHint.fold("N")(n => s"S($n)")})" - case PolyType(targs, body) => s"PolyType(Ls(${targs.iterator.map(_.fold(apply, apply)).mkString(", ")}), ${apply(body)})" - case Signature(members, result) => s"Signature(${members.iterator.map(apply(_: Statement)).mkString("Ls(", ", ", ")")}, ${apply(result)})" - case t: NuDecl => apply(t: Statement) - } - - private def ifBody(body: IfBody): Str = body match { - case IfElse(expr) => s"IfElse(${apply(expr)}" - case IfThen(expr, rhs) => s"IfThen(${apply(expr)}, ${apply(rhs)}" - case IfBlock(lines) => s"IfBlock(${ - lines.iterator.map(_.fold(apply, apply)).mkString("Ls(", ", ", ")") - })" - case IfOpsApp(lhs, opsRhss) => s"IfOpsApp(${apply(lhs)}, ${ - opsRhss.iterator.map { case (op, body) => - s"$op -> ${apply(body)}" - } - }".mkString("; ") - case IfLet(isRec, name, rhs, body) => ??? - case IfOpApp(lhs, op, rhs) => - s"IfOpApp(${apply(lhs)}, ${apply(op)}, ${apply(rhs)}" - } - - private def typingUnit(t: TypingUnit): Str = t.entities.iterator - .map(apply) - .mkString("TypingUnit(", ", ", ")") - } -} \ No newline at end of file diff --git a/shared/src/test/diff/basics/Blocks.fun b/shared/src/test/diff/basics/Blocks.fun index 3d0a46eeb..059b5e80d 100644 --- a/shared/src/test/diff/basics/Blocks.fun +++ b/shared/src/test/diff/basics/Blocks.fun @@ -44,7 +44,7 @@ discard / foo 1 //│ Parsed: discard(...(foo(...{1}))); //│ Desugared: discard(...(foo(...{1}))) -//│ AST: App(Var("discard"), App(Var("foo"), Blk(IntLit(1)))) +//│ AST: App(Var(discard),App(Var(foo),Blk(List(IntLit(1))))) :e discard foo @@ -81,7 +81,7 @@ id id id //│ Parsed: id(...id)(...{id}); //│ Desugared: id(...id)(...{id}) -//│ AST: App(App(Var("id"), Var("id")), Blk(Var("id"))) +//│ AST: App(App(Var(id),Var(id)),Blk(List(Var(id)))) //│ res: 'a -> 'a :p @@ -91,7 +91,7 @@ id id id id id id //│ Parsed: id(...id)(...id)(...{id(...id)(...id)(...{id(...id)(...id)(...{id(...id)(...id)})})}); //│ Desugared: id(...id)(...id)(...{id(...id)(...id)(...{id(...id)(...id)(...{id(...id)(...id)})})}) -//│ AST: App(App(App(Var("id"), Var("id")), Var("id")), Blk(App(App(App(Var("id"), Var("id")), Var("id")), Blk(App(App(App(Var("id"), Var("id")), Var("id")), Blk(App(App(Var("id"), Var("id")), Var("id")))))))) +//│ AST: App(App(App(Var(id),Var(id)),Var(id)),Blk(List(App(App(App(Var(id),Var(id)),Var(id)),Blk(List(App(App(App(Var(id),Var(id)),Var(id)),Blk(List(App(App(Var(id),Var(id)),Var(id))))))))))) //│ res: 'a -> 'a :p @@ -100,7 +100,7 @@ id id / id id //│ Parsed: id(...id)(...{id(...id)(...{id(...id)})}); //│ Desugared: id(...id)(...{id(...id)(...{id(...id)})}) -//│ AST: App(App(Var("id"), Var("id")), Blk(App(App(Var("id"), Var("id")), Blk(App(Var("id"), Var("id")))))) +//│ AST: App(App(Var(id),Var(id)),Blk(List(App(App(Var(id),Var(id)),Blk(List(App(Var(id),Var(id)))))))) //│ res: 'a -> 'a :p @@ -109,7 +109,7 @@ id id id id //│ Parsed: id(...id)(...{id(...id)})(...{id(...id)}); //│ Desugared: id(...id)(...{id(...id)})(...{id(...id)}) -//│ AST: App(App(App(Var("id"), Var("id")), Blk(App(Var("id"), Var("id")))), Blk(App(Var("id"), Var("id")))) +//│ AST: App(App(App(Var(id),Var(id)),Blk(List(App(Var(id),Var(id))))),Blk(List(App(Var(id),Var(id))))) //│ res: 'a -> 'a let foo = diff --git a/shared/src/test/diff/basics/Data.fun b/shared/src/test/diff/basics/Data.fun index d30a7ba97..551c3b1c0 100644 --- a/shared/src/test/diff/basics/Data.fun +++ b/shared/src/test/diff/basics/Data.fun @@ -4,7 +4,7 @@ data Test a b //│ Parsed: data Test(...a)(...b); //│ Desugared: class Test[a, b]: {a: a, b: b} //│ Desugared: def Test: forall a b. (...a) -> (...b) -> Test[a, b] -//│ AST: Def(false, Var("Test"), R(PolyType(Ls(TypeName("a"), TypeName("b")), Function(TypeName("a"), Function(TypeName("b"), AppliedType(TypeName("Test"), TypeName("a") :: TypeName("b") :: Nil))))), true) +//│ AST: Def(false,Var(Test),Right(PolyType(List(Left(TypeName(a)), Left(TypeName(b))),Function(TypeName(a),Function(TypeName(b),AppliedType(TypeName(Test),List(TypeName(a), TypeName(b))))))),true) //│ Defined class Test[+a, +b] //│ Test: 'a -> 'b -> Test['a, 'b] @@ -13,7 +13,7 @@ data Person(name: string, age: int) //│ Parsed: data Person(...'(' {[name: string, age: int,]} ')'); //│ Desugared: class Person: {age: int, name: string} //│ Desugared: def Person: (name: string, age: int) -> Person[] -//│ AST: Def(false, Var("Person"), R(PolyType(Ls(), Function(Tuple(S(name) -> Fld(N, TypeName("string")), S(age) -> Fld(N, TypeName("int"))), AppliedType(TypeName("Person"), Nil)))), true) +//│ AST: Def(false,Var(Person),Right(PolyType(List(),Function(Tuple(List((Some(Var(name)),Field(None,TypeName(string))), (Some(Var(age)),Field(None,TypeName(int))))),AppliedType(TypeName(Person),List())))),true) //│ Defined class Person //│ Person: (name: string, age: int,) -> Person diff --git a/shared/src/test/diff/basics/Datatypes.fun b/shared/src/test/diff/basics/Datatypes.fun index 89f0a6899..02cad3d2c 100644 --- a/shared/src/test/diff/basics/Datatypes.fun +++ b/shared/src/test/diff/basics/Datatypes.fun @@ -6,9 +6,9 @@ data type Boolean of Tru, Fals //│ Desugared: class Tru: {} //│ Desugared: class Fals: {} //│ Desugared: def Tru: Tru[] -//│ AST: Def(false, Var("Tru"), R(PolyType(Ls(), AppliedType(TypeName("Tru"), Nil))), true) +//│ AST: Def(false,Var(Tru),Right(PolyType(List(),AppliedType(TypeName(Tru),List()))),true) //│ Desugared: def Fals: Fals[] -//│ AST: Def(false, Var("Fals"), R(PolyType(Ls(), AppliedType(TypeName("Fals"), Nil))), true) +//│ AST: Def(false,Var(Fals),Right(PolyType(List(),AppliedType(TypeName(Fals),List()))),true) //│ Defined type alias Boolean //│ Defined class Tru //│ Defined class Fals @@ -29,7 +29,7 @@ data type Bool2 of True2 & False2 //│ Desugared: type alias Bool2 = &[True2, False2] //│ Desugared: class &[True2, False2]: {False2 <: False2, True2 <: True2} //│ Desugared: def &: forall True2 False2. (...True2) -> (...False2) -> &[True2, False2] -//│ AST: Def(false, Var("&"), R(PolyType(Ls(TypeName("True2"), TypeName("False2")), Function(TypeName("True2"), Function(TypeName("False2"), AppliedType(TypeName("&"), TypeName("True2") :: TypeName("False2") :: Nil))))), true) +//│ AST: Def(false,Var(&),Right(PolyType(List(Left(TypeName(True2)), Left(TypeName(False2))),Function(TypeName(True2),Function(TypeName(False2),AppliedType(TypeName(&),List(TypeName(True2), TypeName(False2))))))),true) //│ ╔══[ERROR] type identifier not found: True2 //│ ║ l.27: data type Bool2 of True2 & False2 //│ ╙── ^^^^^ @@ -122,9 +122,9 @@ data type List a of //│ Desugared: class Nil[a]: {} //│ Desugared: class Cons[a]: {head: a, tail: anything} //│ Desugared: def Nil: forall a. Nil[a] -//│ AST: Def(false, Var("Nil"), R(PolyType(Ls(TypeName("a")), AppliedType(TypeName("Nil"), TypeName("a") :: Nil))), true) +//│ AST: Def(false,Var(Nil),Right(PolyType(List(Left(TypeName(a))),AppliedType(TypeName(Nil),List(TypeName(a))))),true) //│ Desugared: def Cons: forall a. (head: a) -> (tail: anything) -> Cons[a] -//│ AST: Def(false, Var("Cons"), R(PolyType(Ls(TypeName("a")), Function(Tuple(S(head) -> Fld(N, TypeName("a"))), Function(Tuple(S(tail) -> Fld(N, Top)), AppliedType(TypeName("Cons"), TypeName("a") :: Nil))))), true) +//│ AST: Def(false,Var(Cons),Right(PolyType(List(Left(TypeName(a))),Function(Tuple(List((Some(Var(head)),Field(None,TypeName(a))))),Function(Tuple(List((Some(Var(tail)),Field(None,Top)))),AppliedType(TypeName(Cons),List(TypeName(a))))))),true) //│ Defined type alias List[+a] //│ Defined class Nil[±a] //│ Defined class Cons[+a] @@ -144,7 +144,7 @@ data type Ls of LsA a //│ Desugared: type alias Ls = LsA[a] //│ Desugared: class LsA[a]: {a: a} //│ Desugared: def LsA: forall a. (...a) -> LsA[a] -//│ AST: Def(false, Var("LsA"), R(PolyType(Ls(TypeName("a")), Function(TypeName("a"), AppliedType(TypeName("LsA"), TypeName("a") :: Nil)))), true) +//│ AST: Def(false,Var(LsA),Right(PolyType(List(Left(TypeName(a))),Function(TypeName(a),AppliedType(TypeName(LsA),List(TypeName(a)))))),true) //│ ╔══[ERROR] type identifier not found: a //│ ║ l.142: data type Ls of LsA a //│ ╙── ^ @@ -159,7 +159,7 @@ data type Ls2 of LsA2 `a //│ Desugared: type alias Ls2 = LsA2[] //│ Desugared: class LsA2: {`a: 'a} //│ Desugared: def LsA2: (...'a) -> LsA2[] -//│ AST: Def(false, Var("LsA2"), R(PolyType(Ls(), Function(TypeVar(R(a), N), AppliedType(TypeName("LsA2"), Nil)))), true) +//│ AST: Def(false,Var(LsA2),Right(PolyType(List(),Function(a,AppliedType(TypeName(LsA2),List())))),true) //│ ╔══[ERROR] cannot inherit from a polymorphic type //│ ║ l.157: data type Ls2 of LsA2 `a //│ ╙── ^^^^^^^ diff --git a/shared/src/test/diff/basics/Either.fun b/shared/src/test/diff/basics/Either.fun index 02a365567..a9a49120a 100644 --- a/shared/src/test/diff/basics/Either.fun +++ b/shared/src/test/diff/basics/Either.fun @@ -9,9 +9,9 @@ data type Either l r of //│ Desugared: class Left[l, r]: {l: l} //│ Desugared: class Right[l, r]: {r: r} //│ Desugared: def Left: forall l r. (...l) -> Left[l, r] -//│ AST: Def(false, Var("Left"), R(PolyType(Ls(TypeName("l"), TypeName("r")), Function(TypeName("l"), AppliedType(TypeName("Left"), TypeName("l") :: TypeName("r") :: Nil)))), true) +//│ AST: Def(false,Var(Left),Right(PolyType(List(Left(TypeName(l)), Left(TypeName(r))),Function(TypeName(l),AppliedType(TypeName(Left),List(TypeName(l), TypeName(r)))))),true) //│ Desugared: def Right: forall l r. (...r) -> Right[l, r] -//│ AST: Def(false, Var("Right"), R(PolyType(Ls(TypeName("l"), TypeName("r")), Function(TypeName("r"), AppliedType(TypeName("Right"), TypeName("l") :: TypeName("r") :: Nil)))), true) +//│ AST: Def(false,Var(Right),Right(PolyType(List(Left(TypeName(l)), Left(TypeName(r))),Function(TypeName(r),AppliedType(TypeName(Right),List(TypeName(l), TypeName(r)))))),true) //│ Defined type alias Either[+l, +r] //│ Defined class Left[+l, ±r] //│ Defined class Right[±l, +r] diff --git a/shared/src/test/diff/basics/Flow.fun b/shared/src/test/diff/basics/Flow.fun index 16b7c5a1d..8c363a2cb 100644 --- a/shared/src/test/diff/basics/Flow.fun +++ b/shared/src/test/diff/basics/Flow.fun @@ -6,9 +6,9 @@ data R x //│ Desugared: class L[x]: {x: x} //│ Desugared: class R[x]: {x: x} //│ Desugared: def L: forall x. (...x) -> L[x] -//│ AST: Def(false, Var("L"), R(PolyType(Ls(TypeName("x")), Function(TypeName("x"), AppliedType(TypeName("L"), TypeName("x") :: Nil)))), true) +//│ AST: Def(false,Var(L),Right(PolyType(List(Left(TypeName(x))),Function(TypeName(x),AppliedType(TypeName(L),List(TypeName(x)))))),true) //│ Desugared: def R: forall x. (...x) -> R[x] -//│ AST: Def(false, Var("R"), R(PolyType(Ls(TypeName("x")), Function(TypeName("x"), AppliedType(TypeName("R"), TypeName("x") :: Nil)))), true) +//│ AST: Def(false,Var(R),Right(PolyType(List(Left(TypeName(x))),Function(TypeName(x),AppliedType(TypeName(R),List(TypeName(x)))))),true) //│ Defined class L[+x] //│ Defined class R[+x] //│ L: 'a -> L['a] diff --git a/shared/src/test/diff/basics/Operators.fun b/shared/src/test/diff/basics/Operators.fun index 845354e70..895e9dd48 100644 --- a/shared/src/test/diff/basics/Operators.fun +++ b/shared/src/test/diff/basics/Operators.fun @@ -16,7 +16,7 @@ a + b //│ Parsed: +(...a)(...{b}); //│ Desugared: +(...a)(...{b}) -//│ AST: App(App(Var("+"), Var("a")), Blk(Var("b"))) +//│ AST: App(App(Var(+),Var(a)),Blk(List(Var(b)))) //│ res: int :pe @@ -31,7 +31,7 @@ succ a + c //│ Parsed: +(...(succ(...a)))(...{+(...b)(...{c})}); //│ Desugared: +(...(succ(...a)))(...{+(...b)(...{c})}) -//│ AST: App(App(Var("+"), App(Var("succ"), Var("a"))), Blk(App(App(Var("+"), Var("b")), Blk(Var("c"))))) +//│ AST: App(App(Var(+),App(Var(succ),Var(a))),Blk(List(App(App(Var(+),Var(b)),Blk(List(Var(c))))))) //│ res: int :p @@ -40,7 +40,7 @@ succ / a + c //│ Parsed: succ(...(+(...a)(...{+(...b)(...{c})}))); //│ Desugared: succ(...(+(...a)(...{+(...b)(...{c})}))) -//│ AST: App(Var("succ"), App(App(Var("+"), Var("a")), Blk(App(App(Var("+"), Var("b")), Blk(Var("c")))))) +//│ AST: App(Var(succ),App(App(Var(+),Var(a)),Blk(List(App(App(Var(+),Var(b)),Blk(List(Var(c)))))))) //│ res: int :p @@ -55,11 +55,11 @@ a + d //│ Parsed: +(...a)(...b); +(...(+(...a)(...b)))(...c); +(...(+(...(+(...a)(...b)))(...c)))(...d); //│ Desugared: +(...a)(...b) -//│ AST: App(App(Var("+"), Var("a")), Var("b")) +//│ AST: App(App(Var(+),Var(a)),Var(b)) //│ Desugared: +(...(+(...a)(...b)))(...c) -//│ AST: App(App(Var("+"), App(App(Var("+"), Var("a")), Var("b"))), Var("c")) +//│ AST: App(App(Var(+),App(App(Var(+),Var(a)),Var(b))),Var(c)) //│ Desugared: +(...(+(...(+(...a)(...b)))(...c)))(...d) -//│ AST: App(App(Var("+"), App(App(Var("+"), App(App(Var("+"), Var("a")), Var("b"))), Var("c"))), Var("d")) +//│ AST: App(App(Var(+),App(App(Var(+),App(App(Var(+),Var(a)),Var(b))),Var(c))),Var(d)) //│ res: int //│ res: int //│ res: int @@ -74,7 +74,7 @@ a + d //│ Parsed: +(...(+(...(+(...a)(...b)))(...(+(...(+(...c)(...1)))(...(+(...2)(...3)))))))(...d); //│ Desugared: +(...(+(...(+(...a)(...b)))(...(+(...(+(...c)(...1)))(...(+(...2)(...3)))))))(...d) -//│ AST: App(App(Var("+"), App(App(Var("+"), App(App(Var("+"), Var("a")), Var("b"))), App(App(Var("+"), App(App(Var("+"), Var("c")), IntLit(1))), App(App(Var("+"), IntLit(2)), IntLit(3))))), Var("d")) +//│ AST: App(App(Var(+),App(App(Var(+),App(App(Var(+),Var(a)),Var(b))),App(App(Var(+),App(App(Var(+),Var(c)),IntLit(1))),App(App(Var(+),IntLit(2)),IntLit(3))))),Var(d)) //│ res: int :pe @@ -112,7 +112,7 @@ succ + c //│ Parsed: +(...(succ(...{+(...a)(...b)})))(...c); //│ Desugared: +(...(succ(...{+(...a)(...b)})))(...c) -//│ AST: App(App(Var("+"), App(Var("succ"), Blk(App(App(Var("+"), Var("a")), Var("b"))))), Var("c")) +//│ AST: App(App(Var(+),App(Var(succ),Blk(List(App(App(Var(+),Var(a)),Var(b)))))),Var(c)) //│ res: int // Maybe allow this as it lets us nicely align the operands? diff --git a/shared/src/test/diff/basics/Slashes.fun b/shared/src/test/diff/basics/Slashes.fun index 09db214d6..d4c331609 100644 --- a/shared/src/test/diff/basics/Slashes.fun +++ b/shared/src/test/diff/basics/Slashes.fun @@ -23,7 +23,7 @@ x => succ / succ / x + 1 foo / x => succ / succ / x //│ Parsed: foo(...((...x) => succ(...(succ(...x))))); //│ Desugared: foo(...((...x) => succ(...(succ(...x))))) -//│ AST: App(Var("foo"), Lam(Var("x"), App(Var("succ"), App(Var("succ"), Var("x"))))) +//│ AST: App(Var(foo),Lam(Var(x),App(Var(succ),App(Var(succ),Var(x))))) //│ res: int :e diff --git a/shared/src/test/diff/mlscript/Basics.mls b/shared/src/test/diff/mlscript/Basics.mls index 2fb3e1b4a..b93076134 100644 --- a/shared/src/test/diff/mlscript/Basics.mls +++ b/shared/src/test/diff/mlscript/Basics.mls @@ -96,7 +96,7 @@ def f (x y z) = add x y //│ ╙── ^^^^^ //│ f: error -> int //│ Code generation encountered an error: -//│ term App(App(Var("x"), Tup((N, Var("y")))), Tup((N, Var("z")))) is not a valid pattern +//│ term App(App(Var(x),Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))),Tup(List((None,Fld(FldFlags(false,false,false),Var(z)))))) is not a valid pattern f 1 //│ res: int diff --git a/shared/src/test/diff/mlscript/ByNameByValue.mls b/shared/src/test/diff/mlscript/ByNameByValue.mls index 5d4816180..ddef8f3d9 100644 --- a/shared/src/test/diff/mlscript/ByNameByValue.mls +++ b/shared/src/test/diff/mlscript/ByNameByValue.mls @@ -16,7 +16,7 @@ def incr x = x.a <- x.a + 1 def gensym = let n = { mut a = 0 } in fun () -> (incr n, n) //│ Parsed: def gensym: let n = {mut a: 0} in () => [incr(n,), n,]; //│ Desugared: def gensym: let n = {mut a: 0} in () => [incr(n,), n,] -//│ AST: Def(false, Var("gensym"), L(Let(false, n, Rcd(Var("a") = IntLit(0)), Lam(Tup(), Tup((N, App(Var("incr"), Tup((N, Var("n"))))), (N, Var("n")))))), true) +//│ AST: Def(false,Var(gensym),Left(Let(false,Var(n),Rcd(List((Var(a),Fld(FldFlags(true,false,false),IntLit(0))))),Lam(Tup(List()),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(incr),Tup(List((None,Fld(FldFlags(false,false,false),Var(n)))))))), (None,Fld(FldFlags(false,false,false),Var(n)))))))),true) //│ // Query 1 //│ globalThis.gensym = function gensym() { //│ return (((n) => () => [ @@ -35,7 +35,7 @@ def gensym = let n = { mut a = 0 } in fun () -> (incr n, n) gensym1 = let n = { mut a = 0 } in fun () -> (incr n, n) //│ Parsed: let gensym1 = let n = {mut a: 0} in () => [incr(n,), n,]; //│ Desugared: def gensym1: let n = {mut a: 0} in () => [incr(n,), n,] -//│ AST: Def(false, Var("gensym1"), L(Let(false, n, Rcd(Var("a") = IntLit(0)), Lam(Tup(), Tup((N, App(Var("incr"), Tup((N, Var("n"))))), (N, Var("n")))))), false) +//│ AST: Def(false,Var(gensym1),Left(Let(false,Var(n),Rcd(List((Var(a),Fld(FldFlags(true,false,false),IntLit(0))))),Lam(Tup(List()),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(incr),Tup(List((None,Fld(FldFlags(false,false,false),Var(n)))))))), (None,Fld(FldFlags(false,false,false),Var(n)))))))),false) //│ // Query 1 //│ globalThis.gensym1 = ((n) => () => [ //│ incr(n), diff --git a/shared/src/test/diff/mlscript/MultiArgs.mls b/shared/src/test/diff/mlscript/MultiArgs.mls index 738d35676..996bc44af 100644 --- a/shared/src/test/diff/mlscript/MultiArgs.mls +++ b/shared/src/test/diff/mlscript/MultiArgs.mls @@ -75,9 +75,9 @@ f = fun (x, y) -> add x y f(1, 2) //│ Parsed: let f = (x, y,) => add(x,)(y,); f(1, 2,); //│ Desugared: def f: (x, y,) => add(x,)(y,) -//│ AST: Def(false, Var("f"), L(Lam(Tup((N, Var("x")), (N, Var("y"))), App(App(Var("add"), Tup((N, Var("x")))), Tup((N, Var("y")))))), false) +//│ AST: Def(false,Var(f),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y))))),App(App(Var(add),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))))),false) //│ Desugared: f(1, 2,) -//│ AST: App(Var("f"), Tup((N, IntLit(1)), (N, IntLit(2)))) +//│ AST: App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),IntLit(2)))))) //│ f: (int, int,) -> int //│ = [Function: f] //│ res: int @@ -119,9 +119,9 @@ f = fun ((x, y)) -> add x y f((1, 2)) //│ Parsed: let f = ('(' [x, y,] ')',) => add(x,)(y,); f('(' [1, 2,] ')',); //│ Desugared: def f: ('(' [x, y,] ')',) => add(x,)(y,) -//│ AST: Def(false, Var("f"), L(Lam(Tup((N, Bra(rcd = false, Tup((N, Var("x")), (N, Var("y")))))), App(App(Var("add"), Tup((N, Var("x")))), Tup((N, Var("y")))))), false) +//│ AST: Def(false,Var(f),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Bra(false,Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))))))),App(App(Var(add),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))))),false) //│ Desugared: f('(' [1, 2,] ')',) -//│ AST: App(Var("f"), Tup((N, Bra(rcd = false, Tup((N, IntLit(1)), (N, IntLit(2))))))) +//│ AST: App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),Bra(false,Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),IntLit(2))))))))))) //│ f: ((int, int,),) -> int //│ = [Function: f1] //│ res: int diff --git a/shared/src/test/diff/mlscript/Mut.mls b/shared/src/test/diff/mlscript/Mut.mls index 20bb9fc22..7cbd3ed19 100644 --- a/shared/src/test/diff/mlscript/Mut.mls +++ b/shared/src/test/diff/mlscript/Mut.mls @@ -613,7 +613,7 @@ b1.x <- 1 + 2 <- 4 //│ ║ l.550: b1.x <- 1 + 2 <- 4 //│ ╙── ^ //│ Code generation encountered an error: -//│ illegal assignemnt left-hand side: Bra(rcd = false, Assign(Sel(Var("mt1"), 0), Sel(Var("b1"), t))) +//│ illegal assignemnt left-hand side: Bra(false,Assign(Sel(Var(mt1),Var(0)),Sel(Var(b1),Var(t)))) def f : {mut 0 : int} -> int -> unit def g : (mut int, bool) -> int -> unit diff --git a/shared/src/test/diff/mlscript/Ops.mls b/shared/src/test/diff/mlscript/Ops.mls index f0ea6554d..6dbb47205 100644 --- a/shared/src/test/diff/mlscript/Ops.mls +++ b/shared/src/test/diff/mlscript/Ops.mls @@ -3,7 +3,7 @@ 2 + 2 //│ Parsed: +(2,)(2,); //│ Desugared: +(2,)(2,) -//│ AST: App(App(Var("+"), Tup((N, IntLit(2)))), Tup((N, IntLit(2)))) +//│ AST: App(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))) //│ res: int //│ = 4 @@ -11,7 +11,7 @@ 1 + 2 * 2 + 3 //│ Parsed: +(+(1,)(*(2,)(2,),),)(3,); //│ Desugared: +(+(1,)(*(2,)(2,),),)(3,) -//│ AST: App(App(Var("+"), Tup((N, App(App(Var("+"), Tup((N, IntLit(1)))), Tup((N, App(App(Var("*"), Tup((N, IntLit(2)))), Tup((N, IntLit(2)))))))))), Tup((N, IntLit(3)))) +//│ AST: App(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(*),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))))))))))))),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(3)))))) //│ res: int //│ = 8 @@ -20,7 +20,7 @@ 1 + 2 / 2 + 3 //│ Parsed: +(+(1,)(/(2,)(2,),),)(3,); //│ Desugared: +(+(1,)(/(2,)(2,),),)(3,) -//│ AST: App(App(Var("+"), Tup((N, App(App(Var("+"), Tup((N, IntLit(1)))), Tup((N, App(App(Var("/"), Tup((N, IntLit(2)))), Tup((N, IntLit(2)))))))))), Tup((N, IntLit(3)))) +//│ AST: App(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(/),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))))))))))))),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(3)))))) //│ ╔══[ERROR] Type mismatch in operator application: //│ ║ l.20: 1 + 2 / 2 + 3 //│ ║ ^^^^^^^^^ @@ -36,7 +36,7 @@ 1 |> 2 || 3 //│ Parsed: ||(|>(1,)(2,),)(3,); //│ Desugared: ||(|>(1,)(2,),)(3,) -//│ AST: App(App(Var("||"), Tup((N, App(App(Var("|>"), Tup((N, IntLit(1)))), Tup((N, IntLit(2))))))), Tup((N, IntLit(3)))) +//│ AST: App(App(Var(||),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(|>),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2))))))))))),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(3)))))) //│ ╔══[ERROR] identifier not found: |> //│ ║ l.36: 1 |> 2 || 3 //│ ╙── ^^ @@ -54,7 +54,7 @@ true || false && true || false //│ Parsed: ||(||(true,)(&&(false,)(true,),),)(false,); //│ Desugared: ||(||(true,)(&&(false,)(true,),),)(false,) -//│ AST: App(App(Var("||"), Tup((N, App(App(Var("||"), Tup((N, Var("true")))), Tup((N, App(App(Var("&&"), Tup((N, Var("false")))), Tup((N, Var("true")))))))))), Tup((N, Var("false")))) +//│ AST: App(App(Var(||),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(||),Tup(List((None,Fld(FldFlags(false,false,false),Var(true)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(&&),Tup(List((None,Fld(FldFlags(false,false,false),Var(false)))))),Tup(List((None,Fld(FldFlags(false,false,false),Var(true)))))))))))))))),Tup(List((None,Fld(FldFlags(false,false,false),Var(false)))))) //│ res: bool //│ = true diff --git a/shared/src/test/diff/mlscript/Weird.mls b/shared/src/test/diff/mlscript/Weird.mls index ffc7a116c..2b658ed4e 100644 --- a/shared/src/test/diff/mlscript/Weird.mls +++ b/shared/src/test/diff/mlscript/Weird.mls @@ -41,9 +41,9 @@ class C def n: C{} //│ Parsed: rec def n: C; {}; //│ Desugared: rec def n: C -//│ AST: Def(true, Var("n"), R(PolyType(Ls(), TypeName("C"))), true) +//│ AST: Def(true,Var(n),Right(PolyType(List(),TypeName(C))),true) //│ Desugared: {} -//│ AST: Rcd() +//│ AST: Rcd(List()) //│ n: C //│ = //│ res: anything diff --git a/shared/src/test/diff/nu/AbstractClasses.mls b/shared/src/test/diff/nu/AbstractClasses.mls index c00679e1b..96dcb79c9 100644 --- a/shared/src/test/diff/nu/AbstractClasses.mls +++ b/shared/src/test/diff/nu/AbstractClasses.mls @@ -51,7 +51,7 @@ new Foo(1) { fun f = id } //│ ╙── ^^^^^^^^^^^^^^^^^^^^^^^^^ //│ error //│ Code generation encountered an error: -//│ cannot generate code for term Rft(App(NuNew(Var("Foo")), Tup((N, IntLit(1)))), TypingUnit(NuFunDef(None, f, N, Nil, L(Var("id"))))) +//│ cannot generate code for term Rft(App(NuNew(Var(Foo)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))),TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Var(id)))))) abstract class Bar extends Foo(1) diff --git a/shared/src/test/diff/nu/BadBlocks.mls b/shared/src/test/diff/nu/BadBlocks.mls index 03fb69ccf..2e9898637 100644 --- a/shared/src/test/diff/nu/BadBlocks.mls +++ b/shared/src/test/diff/nu/BadBlocks.mls @@ -176,5 +176,5 @@ fun test = (new { //│ ╙── ^ //│ fun test: error //│ Code generation encountered an error: -//│ Unsupported `new` class term: Bra(rcd = true, Rcd(Var("res") = Var("res"))) +//│ Unsupported `new` class term: Bra(true,Rcd(List((Var(res),Fld(FldFlags(false,false,true),Var(res)))))) diff --git a/shared/src/test/diff/nu/LamPatterns.mls b/shared/src/test/diff/nu/LamPatterns.mls index 98bb1511b..0b4537909 100644 --- a/shared/src/test/diff/nu/LamPatterns.mls +++ b/shared/src/test/diff/nu/LamPatterns.mls @@ -14,7 +14,7 @@ Some(x) => x //│ ╙── ^ //│ error -> error //│ Code generation encountered an error: -//│ term App(Var("Some"), Tup((N, Var("x")))) is not a valid pattern +//│ term App(Var(Some),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))) is not a valid pattern :js // FIXME type diff --git a/shared/src/test/diff/nu/LetRec.mls b/shared/src/test/diff/nu/LetRec.mls index 51ad7c37f..f990934e2 100644 --- a/shared/src/test/diff/nu/LetRec.mls +++ b/shared/src/test/diff/nu/LetRec.mls @@ -129,7 +129,7 @@ let rec lol = () => lol :p let rec f = 1 //│ |#let| |#rec| |f| |#=| |1| -//│ AST: TypingUnit(NuFunDef(Some(true), f, N, Nil, L(IntLit(1)))) +//│ AST: TypingUnit(List(NuFunDef(Some(true),Var(f),None,List(),Left(IntLit(1))))) //│ Parsed: let rec f = 1; //│ let rec f: 1 //│ f diff --git a/shared/src/test/diff/nu/NewNew.mls b/shared/src/test/diff/nu/NewNew.mls index 86753b6e3..b043836ce 100644 --- a/shared/src/test/diff/nu/NewNew.mls +++ b/shared/src/test/diff/nu/NewNew.mls @@ -167,7 +167,7 @@ new PoInt['_] //│ ╙── ^ //│ PoInt[nothing] | error //│ Code generation encountered an error: -//│ Unsupported `new` class term: TyApp(Var("PoInt"), List('_)) +//│ Unsupported `new` class term: TyApp(Var(PoInt),List('_)) :e new PoInt[Str](0, 0) @@ -176,7 +176,7 @@ new PoInt[Str](0, 0) //│ ╙── ^^^^^^^^^^^^^^^^^^^^ //│ PoInt[0] //│ Code generation encountered an error: -//│ Unsupported `new` class term: TyApp(Var("PoInt"), List(TypeName(Str))) +//│ Unsupported `new` class term: TyApp(Var(PoInt),List(TypeName(Str))) type T = PoInt[Str] //│ type T = PoInt[Str] @@ -211,7 +211,7 @@ let origin = new PoInt[Int](0, 0) //│ ╙── ^^^^^^^^^^^^^^^^^^^^ //│ let origin: PoInt[0] //│ Code generation encountered an error: -//│ Unsupported `new` class term: TyApp(Var("PoInt"), List(TypeName(Int))) +//│ Unsupported `new` class term: TyApp(Var(PoInt),List(TypeName(Int))) :e // TODO support @@ -221,7 +221,7 @@ new {} //│ ╙── ^^ //│ error //│ Code generation encountered an error: -//│ Unsupported `new` class term: Bra(rcd = true, Rcd()) +//│ Unsupported `new` class term: Bra(true,Rcd(List())) :pe :e @@ -247,7 +247,7 @@ new //│ ╙── ^ //│ error //│ Code generation encountered an error: -//│ Unsupported `new` class term: Blk(Asc(Var("x"), Literal(0))) +//│ Unsupported `new` class term: Blk(List(Asc(Var(x),Literal(IntLit(0))))) @@ -302,6 +302,6 @@ module A { class B } new A.B //│ B //│ Code generation encountered an error: -//│ Unsupported `new` class term: Sel(Var("A"), B) +//│ Unsupported `new` class term: Sel(Var(A),Var(B)) diff --git a/shared/src/test/diff/nu/OpLam.mls b/shared/src/test/diff/nu/OpLam.mls index ec57b8f85..b7eb786b5 100644 --- a/shared/src/test/diff/nu/OpLam.mls +++ b/shared/src/test/diff/nu/OpLam.mls @@ -107,6 +107,6 @@ x => x.y => y //│ ╙── ^ //│ anything -> error -> error //│ Code generation encountered an error: -//│ term Sel(Var("x"), y) is not a valid pattern +//│ term Sel(Var(x),Var(y)) is not a valid pattern diff --git a/shared/src/test/diff/nu/OverrideShorthand.mls b/shared/src/test/diff/nu/OverrideShorthand.mls index 8383f5a73..5f3392d15 100644 --- a/shared/src/test/diff/nu/OverrideShorthand.mls +++ b/shared/src/test/diff/nu/OverrideShorthand.mls @@ -10,7 +10,7 @@ class Pair(lhs: Int, rhs: Int) :e fun f(override Pair(x, y)) = x + y //│ |#fun| |f|(|#override| |Pair|(|x|,| |y|)|)| |#=| |x| |+| |y| -//│ AST: TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("_$0"))), If(IfOpApp(Var("_$0"), Var("is"), IfThen(App(Var("Pair"), Tup((N, Var("x")), (N, Var("y")))), App(Var("+"), Tup((N, Var("x")), (N, Var("y")))), Some(App(Sel(Super(), f), Tup((N, Var("_$0")))))))))) +//│ AST: TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(_$0))))),If(IfOpApp(Var(_$0),Var(is),IfThen(App(Var(Pair),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))))),Some(App(Sel(Super(),Var(f)),Tup(List((None,Fld(FldFlags(false,false,false),Var(_$0))))))))))))) //│ Parsed: fun f = (_$0,) => if _$0 is (Pair(x, y,)) then +(x, y,) else (super).f(_$0,); //│ ╔══[ERROR] identifier not found: super //│ ║ l.11: fun f(override Pair(x, y)) = x + y @@ -46,7 +46,7 @@ fun f(override Pair(x, y), z) = x + y //│ ╙── ^ //│ fun f: (error, anything) -> Int //│ Code generation encountered an error: -//│ term App(Var("Pair"), Tup((N, Var("x")), (N, Var("y")))) is not a valid pattern +//│ term App(Var(Pair),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))) is not a valid pattern // TODO diff --git a/shared/src/test/diff/nu/Refinements.mls b/shared/src/test/diff/nu/Refinements.mls index 2311c3c10..62a2a6790 100644 --- a/shared/src/test/diff/nu/Refinements.mls +++ b/shared/src/test/diff/nu/Refinements.mls @@ -83,7 +83,7 @@ let r = new {} //│ ╙── ^^ //│ let r: error //│ Code generation encountered an error: -//│ Unsupported `new` class term: Bra(rcd = true, Rcd()) +//│ Unsupported `new` class term: Bra(true,Rcd(List())) :ge r : Object diff --git a/shared/src/test/diff/nu/RightAssocOps.mls b/shared/src/test/diff/nu/RightAssocOps.mls index df5969158..f6738db61 100644 --- a/shared/src/test/diff/nu/RightAssocOps.mls +++ b/shared/src/test/diff/nu/RightAssocOps.mls @@ -30,7 +30,7 @@ fun (++) conc(xs, ys) = [xs, ys] :p 1 +: "a" ++ "b" :+ 2 //│ |1| |+:| |"a"| |++| |"b"| |:+| |2| -//│ AST: TypingUnit(App(Var("+:"), Tup((N, IntLit(1)), (N, App(Var(":+"), Tup((N, App(Var("++"), Tup((N, StrLit(a)), (N, StrLit(b))))), (N, IntLit(2)))))))) +//│ AST: TypingUnit(List(App(Var(+:),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(Var(:+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(++),Tup(List((None,Fld(FldFlags(false,false,false),StrLit(a))), (None,Fld(FldFlags(false,false,false),StrLit(b)))))))), (None,Fld(FldFlags(false,false,false),IntLit(2))))))))))))) //│ Parsed: +:(1, :+(++("a", "b",), 2,),); //│ [[Int], [["a", "b"], [Int]]] //│ res @@ -39,7 +39,7 @@ fun (++) conc(xs, ys) = [xs, ys] :p 1 +: "a" :+ 2 ++ "b" //│ |1| |+:| |"a"| |:+| |2| |++| |"b"| -//│ AST: TypingUnit(App(Var("+:"), Tup((N, IntLit(1)), (N, App(Var("++"), Tup((N, App(Var(":+"), Tup((N, StrLit(a)), (N, IntLit(2))))), (N, StrLit(b)))))))) +//│ AST: TypingUnit(List(App(Var(+:),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(Var(++),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(:+),Tup(List((None,Fld(FldFlags(false,false,false),StrLit(a))), (None,Fld(FldFlags(false,false,false),IntLit(2)))))))), (None,Fld(FldFlags(false,false,false),StrLit(b))))))))))))) //│ Parsed: +:(1, ++(:+("a", 2,), "b",),); //│ [[Int], [["a", [Int]], "b"]] //│ res @@ -49,7 +49,7 @@ fun (++) conc(xs, ys) = [xs, ys] :e 1 +: "a" ++ 2 +: "b" //│ |1| |+:| |"a"| |++| |2| |+:| |"b"| -//│ AST: TypingUnit(App(Var("+:"), Tup((N, IntLit(1)), (N, App(Var("+:"), Tup((N, App(Var("++"), Tup((N, StrLit(a)), (N, IntLit(2))))), (N, StrLit(b)))))))) +//│ AST: TypingUnit(List(App(Var(+:),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(Var(+:),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(++),Tup(List((None,Fld(FldFlags(false,false,false),StrLit(a))), (None,Fld(FldFlags(false,false,false),IntLit(2)))))))), (None,Fld(FldFlags(false,false,false),StrLit(b))))))))))))) //│ Parsed: +:(1, +:(++("a", 2,), "b",),); //│ ╔══[ERROR] Type mismatch in operator application: //│ ║ l.50: 1 +: "a" ++ 2 +: "b" diff --git a/shared/src/test/diff/nu/TODO_Classes.mls b/shared/src/test/diff/nu/TODO_Classes.mls index c3cef2e7f..dec21bdd1 100644 --- a/shared/src/test/diff/nu/TODO_Classes.mls +++ b/shared/src/test/diff/nu/TODO_Classes.mls @@ -80,7 +80,7 @@ new C { val x = 1 } //│ ╙── ^^^^^^^^^^^^^^^^^^^ //│ error //│ Code generation encountered an error: -//│ cannot generate code for term Rft(NuNew(Var("C")), TypingUnit(NuFunDef(Some(false), x, N, Nil, L(IntLit(1))))) +//│ cannot generate code for term Rft(NuNew(Var(C)),TypingUnit(List(NuFunDef(Some(false),Var(x),None,List(),Left(IntLit(1)))))) diff --git a/shared/src/test/diff/ucs/LeadingAnd.mls b/shared/src/test/diff/ucs/LeadingAnd.mls index f1e65d9f1..bb6ac93e0 100644 --- a/shared/src/test/diff/ucs/LeadingAnd.mls +++ b/shared/src/test/diff/ucs/LeadingAnd.mls @@ -23,7 +23,7 @@ fun f(a, b) = if a is Some(av) and b is Some(bv) then av + bv //│ |#fun| |f|(|a|,| |b|)| |#=| |#if| |a| |is| |Some|(|av|)|→|and| |b| |is| |Some|(|bv|)|↵|#then| |av| |+| |bv|←| -//│ AST: TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("a")), (N, Var("b"))), If(IfOpApp(Var("a"), Var("is"), I; f; O; p; s; A; p; p; (; A; p; p; (; V; a; r; (; "; S; o; m; e; "; ); ,; ; T; u; p; (; (; N; ,; ; V; a; r; (; "; a; v; "; ); ); ); ); ,; ; <; i; t; e; r; a; t; o; r; >, None))))) +//│ AST: TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),Var(b))))),If(IfOpApp(Var(a),Var(is),IfOpsApp(App(Var(Some),Tup(List((None,Fld(FldFlags(false,false,false),Var(av)))))),List((Var(and),IfThen(App(Var(is),Tup(List((None,Fld(FldFlags(false,false,false),Var(b))), (None,Fld(FldFlags(false,false,false),App(Var(Some),Tup(List((None,Fld(FldFlags(false,false,false),Var(bv))))))))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(av))), (None,Fld(FldFlags(false,false,false),Var(bv))))))))))),None)))))) //│ Parsed: fun f = (a, b,) => if a is Some(av,) ‹· and (is(b, Some(bv,),)) then +(av, bv,)›; //│ fun f: (Some[Int], Some[Int]) -> Int @@ -34,7 +34,7 @@ fun f(a, b) = if a is and b is Some(bv) then av + bv //│ |#fun| |f|(|a|,| |b|)| |#=| |#if| |a| |is|→|Some|(|av|)|→|and| |b| |is| |Some|(|bv|)|↵|#then| |av| |+| |bv|←|←| -//│ AST: TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("a")), (N, Var("b"))), If(IfOpApp(Var("a"), Var("is"), IfBlock(Ls(I; f; O; p; s; A; p; p; (; A; p; p; (; V; a; r; (; "; S; o; m; e; "; ); ,; ; T; u; p; (; (; N; ,; ; V; a; r; (; "; a; v; "; ); ); ); ); ,; ; <; i; t; e; r; a; t; o; r; >)), None))))) +//│ AST: TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),Var(b))))),If(IfOpApp(Var(a),Var(is),IfBlock(List(Left(IfOpsApp(App(Var(Some),Tup(List((None,Fld(FldFlags(false,false,false),Var(av)))))),List((Var(and),IfThen(App(Var(is),Tup(List((None,Fld(FldFlags(false,false,false),Var(b))), (None,Fld(FldFlags(false,false,false),App(Var(Some),Tup(List((None,Fld(FldFlags(false,false,false),Var(bv))))))))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(av))), (None,Fld(FldFlags(false,false,false),Var(bv)))))))))))))),None)))))) //│ Parsed: fun f = (a, b,) => if a is ‹Some(av,) ‹· and (is(b, Some(bv,),)) then +(av, bv,)››; //│ ╔══[ERROR] Illegal pattern `and` //│ ║ l.34: and b is Some(bv) diff --git a/shared/src/test/diff/ucs/SplitOps.mls b/shared/src/test/diff/ucs/SplitOps.mls index 70e9e0536..6a88e2d49 100644 --- a/shared/src/test/diff/ucs/SplitOps.mls +++ b/shared/src/test/diff/ucs/SplitOps.mls @@ -93,10 +93,10 @@ fun f(a, b, c) = if a == 0 and b is B() and c is C() then 0 //│ |#fun| |f|(|a|,| |b|,| |c|)| |#=|→|#if| |a|→|==| |0| |and| |b| |is| |B|(||)| |and| |c| |is| |C|(||)| |#then| |0|←|←| -//│ AST: TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("a")), (N, Var("b")), (N, Var("c"))), Blk(If(I; f; O; p; s; A; p; p; (; V; a; r; (; "; a; "; ); ,; ; <; i; t; e; r; a; t; o; r; >, None)))))) +//│ AST: TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),Var(b))), (None,Fld(FldFlags(false,false,false),Var(c))))),Blk(List(If(IfOpsApp(Var(a),List((Var(==),IfThen(App(App(Var(and),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(and),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(is),Tup(List((None,Fld(FldFlags(false,false,false),Var(b)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(B),Tup(List()))))))))))))))))),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(is),Tup(List((None,Fld(FldFlags(false,false,false),Var(c)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(C),Tup(List())))))))))))),IntLit(0))))),None)))))))) //│ Parsed: fun f = (a, b, c,) => {if a ‹· == (and(and(0,)(is(b,)(B(),),),)(is(c,)(C(),),)) then 0›}; //│ Desugared: rec def f: (a, b, c,) => {if a ‹· == (and(and(0,)(is(b,)(B(),),),)(is(c,)(C(),),)) then 0›} -//│ AST: Def(true, Var("f"), L(Lam(Tup((N, Var("a")), (N, Var("b")), (N, Var("c"))), Blk(If(I; f; O; p; s; A; p; p; (; V; a; r; (; "; a; "; ); ,; ; <; i; t; e; r; a; t; o; r; >, None)))), true) +//│ AST: Def(true,Var(f),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),Var(b))), (None,Fld(FldFlags(false,false,false),Var(c))))),Blk(List(If(IfOpsApp(Var(a),List((Var(==),IfThen(App(App(Var(and),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(and),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(is),Tup(List((None,Fld(FldFlags(false,false,false),Var(b)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(B),Tup(List()))))))))))))))))),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(is),Tup(List((None,Fld(FldFlags(false,false,false),Var(c)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(C),Tup(List())))))))))))),IntLit(0))))),None))))),true) //│ ╔══[ERROR] The case when this is false is not handled: ==(a,)(0,) //│ ║ l.93: if a //│ ║ ^ diff --git a/shared/src/test/scala/mlscript/DiffTests.scala b/shared/src/test/scala/mlscript/DiffTests.scala index a1c7b721a..b0896150d 100644 --- a/shared/src/test/scala/mlscript/DiffTests.scala +++ b/shared/src/test/scala/mlscript/DiffTests.scala @@ -430,7 +430,7 @@ class DiffTests output("Parsed: " + res.showDbgTop) if (mode.showParse) - output("AST: " + inspect.deep(res)) + output(s"AST: $res") postProcess(mode, basePath, testName, res).foreach(output) @@ -622,7 +622,7 @@ class DiffTests typeDefs.foreach(td => output("Desugared: " + td.showDbg)) stmts.foreach { s => output("Desugared: " + s.showDbg) - output("AST: " + inspect.deep(s)) + output(s"AST: $s") } } From 73b389bc18e7a1ef3ad4c8e1e24d9a13a8ce52b1 Mon Sep 17 00:00:00 2001 From: Luyu Cheng Date: Sun, 31 Dec 2023 03:31:28 +0800 Subject: [PATCH 05/11] Update test files of other sub-projects as well --- compiler/shared/test/diff/LambLift.mls | 8 ++-- compiler/shared/test/diff/LiftType.mls | 10 ++--- compiler/shared/test/diff/Lifter.mls | 30 ++++++------- compiler/shared/test/diff/LifterBlks.mls | 36 ++++++++-------- compiler/shared/test/diff/mono.mls | 54 ++++++++++++------------ 5 files changed, 69 insertions(+), 69 deletions(-) diff --git a/compiler/shared/test/diff/LambLift.mls b/compiler/shared/test/diff/LambLift.mls index b345cbf0a..bbfea08e3 100644 --- a/compiler/shared/test/diff/LambLift.mls +++ b/compiler/shared/test/diff/LambLift.mls @@ -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(),)} @@ -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,)} @@ -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,)} @@ -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,)} diff --git a/compiler/shared/test/diff/LiftType.mls b/compiler/shared/test/diff/LiftType.mls index 183dc1a6b..0d8ea8eaf 100644 --- a/compiler/shared/test/diff/LiftType.mls +++ b/compiler/shared/test/diff/LiftType.mls @@ -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,]) {} @@ -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} @@ -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} @@ -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} @@ -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. //│ diff --git a/compiler/shared/test/diff/Lifter.mls b/compiler/shared/test/diff/Lifter.mls index f074c30a5..d55d43034 100644 --- a/compiler/shared/test/diff/Lifter.mls +++ b/compiler/shared/test/diff/Lifter.mls @@ -28,7 +28,7 @@ class A(x) { //│ |#class| |A|(|x|)| |{|→|#class| |B|(|y|)| |{|→|#fun| |getX| |#=| |x|↵|#fun| |getB1| |#=| |B1|(|y|)|↵|#class| |C|(|z|)| |{|→|#fun| |inc|(||)| |#=| |x| |+| |1|↵|#fun| |getY| |#=| |y|↵|#fun| |getA| |#=| |A|(|z|)|↵|#fun| |getB|(|w|)| |#=| |B|(|w|)|↵|#fun| |getC| |#=| |#new| |C|(|inc|(||)|)|↵|#fun| |getSelf| |#=| |this|←|↵|}|←|↵|}|↵|#class| |B1|(|y|)| |{|→|#fun| |getX| |#=| |x|↵|#fun| |getY| |#=| |y|↵|#fun| |getB| |#=| |#new| |B|(|y|)|↵|#fun| |getB1| |#=| |#new| |B1|(|y|)|←|↵|}|↵|#fun| |getB| |#=| |#new| |B|(|x|)|↵|#fun| |getB2|(|y|)| |#=| |B1|(|y|)|↵|#fun| |getB3|(|z|)| |#=| |getB2|(|z|)|↵|#fun| |getA| |#=| |A|(|x|)|←|↵|}| //│ Parsed: {class A(x,) {class B(y,) {fun getX = x; fun getB1 = B1(y,); class C(z,) {fun inc = () => +(x, 1,); fun getY = y; fun getA = A(z,); fun getB = (w,) => B(w,); fun getC = (new C)(inc(),); fun getSelf = this}}; class B1(y,) {fun getX = x; fun getY = y; fun getB = (new B)(y,); fun getB1 = (new B1)(y,)}; fun getB = (new B)(x,); fun getB2 = (y,) => B1(y,); fun getB3 = (z,) => getB2(z,); fun getA = A(x,)}} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), S(Tup((N, Var("y")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, getX, N, Nil, L(Var("x"))), NuFunDef(None, getB1, N, Nil, L(App(Var("B1"), Tup((N, Var("y")))))), NuTypeDef(Cls, TypeName("C"), Ls(), S(Tup((N, Var("z")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, inc, N, Nil, L(Lam(Tup(), App(Var("+"), Tup((N, Var("x")), (N, IntLit(1))))))), NuFunDef(None, getY, N, Nil, L(Var("y"))), NuFunDef(None, getA, N, Nil, L(App(Var("A"), Tup((N, Var("z")))))), NuFunDef(None, getB, N, Nil, L(Lam(Tup((N, Var("w"))), App(Var("B"), Tup((N, Var("w"))))))), NuFunDef(None, getC, N, Nil, L(App(NuNew(Var("C")), Tup((N, App(Var("inc"), Tup())))))), NuFunDef(None, getSelf, N, Nil, L(Var("this"))))))), NuTypeDef(Cls, TypeName("B1"), Ls(), S(Tup((N, Var("y")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, getX, N, Nil, L(Var("x"))), NuFunDef(None, getY, N, Nil, L(Var("y"))), NuFunDef(None, getB, N, Nil, L(App(NuNew(Var("B")), Tup((N, Var("y")))))), NuFunDef(None, getB1, N, Nil, L(App(NuNew(Var("B1")), Tup((N, Var("y")))))))), NuFunDef(None, getB, N, Nil, L(App(NuNew(Var("B")), Tup((N, Var("x")))))), NuFunDef(None, getB2, N, Nil, L(Lam(Tup((N, Var("y"))), App(Var("B1"), Tup((N, Var("y"))))))), NuFunDef(None, getB3, N, Nil, L(Lam(Tup((N, Var("z"))), App(Var("getB2"), Tup((N, Var("z"))))))), NuFunDef(None, getA, N, Nil, L(App(Var("A"), Tup((N, Var("x"))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(getX),None,List(),Left(Var(x))), NuFunDef(None,Var(getB1),None,List(),Left(App(Var(B1),Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))))), NuTypeDef(Cls,TypeName(C),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(z)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(inc),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))))), NuFunDef(None,Var(getY),None,List(),Left(Var(y))), NuFunDef(None,Var(getA),None,List(),Left(App(Var(A),Tup(List((None,Fld(FldFlags(false,false,false),Var(z)))))))), NuFunDef(None,Var(getB),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(w))))),App(Var(B),Tup(List((None,Fld(FldFlags(false,false,false),Var(w))))))))), NuFunDef(None,Var(getC),None,List(),Left(App(NuNew(Var(C)),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(inc),Tup(List()))))))))), NuFunDef(None,Var(getSelf),None,List(),Left(Var(this))))))))), NuTypeDef(Cls,TypeName(B1),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(getX),None,List(),Left(Var(x))), NuFunDef(None,Var(getY),None,List(),Left(Var(y))), NuFunDef(None,Var(getB),None,List(),Left(App(NuNew(Var(B)),Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))))), NuFunDef(None,Var(getB1),None,List(),Left(App(NuNew(Var(B1)),Tup(List((None,Fld(FldFlags(false,false,false),Var(y))))))))))), NuFunDef(None,Var(getB),None,List(),Left(App(NuNew(Var(B)),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))), NuFunDef(None,Var(getB2),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(y))))),App(Var(B1),Tup(List((None,Fld(FldFlags(false,false,false),Var(y))))))))), NuFunDef(None,Var(getB3),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(z))))),App(Var(getB2),Tup(List((None,Fld(FldFlags(false,false,false),Var(z))))))))), NuFunDef(None,Var(getA),None,List(),Left(App(Var(A),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2_C$4([par$A$1_B$2, z, x,]) { @@ -68,7 +68,7 @@ class A(x) { //│ |#class| |A|(|x|)| |{|→|#class| |B|(|y|)| |{|→|#class| |C|(|z|)| |{|→|#fun| |sum| |#=| |x| |+| |y| |+| |z|←|↵|}|←|↵|}|←|↵|}| //│ Parsed: {class A(x,) {class B(y,) {class C(z,) {fun sum = +(+(x, y,), z,)}}}} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), S(Tup((N, Var("y")))), N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("C"), Ls(), S(Tup((N, Var("z")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, sum, N, Nil, L(App(Var("+"), Tup((N, App(Var("+"), Tup((N, Var("x")), (N, Var("y"))))), (N, Var("z"))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(C),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(z)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(sum),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))))), (None,Fld(FldFlags(false,false,false),Var(z))))))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2_C$3([par$A$1_B$2, z, x,]) { @@ -108,7 +108,7 @@ new C{ //│ |#class| |A|(|x|)| |{|→|#class| |B|{|→|#fun| |foo| |#=| |1|↵|#fun| |bar| |#=| |11|←|↵|}|↵|#fun| |getB| |#=| |#new| |B|{|→|#fun| |foo| |#=| |2|↵|#fun| |bar| |#=| |12|←|↵|}|↵|#fun| |bar| |#=| |13|←|↵|}|↵|#class| |C|#:| |A|{|→|#fun| |getB| |#=| |#new| |B|{|→|#fun| |foo| |#=| |3|↵|#fun| |bar| |#=| |14|←|↵|}|↵|#fun| |bar| |#=| |15|←|↵|}|↵|#new| |C|{|→|#fun| |getB| |#=| |#new| |B|{|→|#fun| |foo| |#=| |4|↵|#fun| |bar| |#=| |16|←|↵|}|↵|#fun| |bar| |#=| |17|←|↵|}| //│ Parsed: {class A(x,) {class B {fun foo = 1; fun bar = 11}; fun getB = new B { ‹fun foo = 2; fun bar = 12› }; fun bar = 13}; class C: A {fun getB = new B { ‹fun foo = 3; fun bar = 14› }; fun bar = 15}; new C { ‹fun getB = new B { ‹fun foo = 4; fun bar = 16› }; fun bar = 17› }} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(1))), NuFunDef(None, bar, N, Nil, L(IntLit(11))))), NuFunDef(None, getB, N, Nil, L(Rft(NuNew(Var("B")), TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(2))), NuFunDef(None, bar, N, Nil, L(IntLit(12))))))), NuFunDef(None, bar, N, Nil, L(IntLit(13))))), NuTypeDef(Cls, TypeName("C"), Ls(), N, N, S(TypeName("A")), Ls(), N, N, TypingUnit(NuFunDef(None, getB, N, Nil, L(Rft(NuNew(Var("B")), TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(3))), NuFunDef(None, bar, N, Nil, L(IntLit(14))))))), NuFunDef(None, bar, N, Nil, L(IntLit(15))))), Rft(NuNew(Var("C")), TypingUnit(NuFunDef(None, getB, N, Nil, L(Rft(NuNew(Var("B")), TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(4))), NuFunDef(None, bar, N, Nil, L(IntLit(16))))))), NuFunDef(None, bar, N, Nil, L(IntLit(17)))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(1))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(11)))))), NuFunDef(None,Var(getB),None,List(),Left(Rft(NuNew(Var(B)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(2))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(12)))))))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(13)))))), NuTypeDef(Cls,TypeName(C),List(),None,None,Some(TypeName(A)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(getB),None,List(),Left(Rft(NuNew(Var(B)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(3))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(14)))))))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(15)))))), Rft(NuNew(Var(C)),TypingUnit(List(NuFunDef(None,Var(getB),None,List(),Left(Rft(NuNew(Var(B)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(4))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(16)))))))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(17)))))))) //│ Lifted: //│ Lifting failed: mlscript.codegen.CodeGenError: Cannot find type B. Class values are not supported in lifter. //│ @@ -125,7 +125,7 @@ class Parent(x) { //│ |#class| |Parent|‹|T|,| |U|,| |V|›|(|x|)| |{| |→|#fun| |foo|(|x|#:| |Int|)|#:| |T| |#=| |x|+|1|↵|#class| |Inner|‹|W|›|(|y|#:| |Int|)|{|→|#fun| |bar|(|z|#:| |U|)| |#=| |foo|(|y|)|↵|#fun| |boo|(|z|#:| |W|)| |#=| |z|←|↵|}|←|↵|}| //│ Parsed: {class Parent‹T, U, V›(x,) {fun foo = (x: Int,) => +(x, 1,) : T; class Inner‹W›(y: Int,) {fun bar = (z: U,) => foo(y,); fun boo = (z: W,) => z}}} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("Parent"), Ls(N -> TypeName("T"), N -> TypeName("U"), N -> TypeName("V")), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup((S(Var("x")), Var("Int"))), Asc(App(Var("+"), Tup((N, Var("x")), (N, IntLit(1)))), TypeName("T"))))), NuTypeDef(Cls, TypeName("Inner"), Ls(N -> TypeName("W")), S(Tup((S(Var("y")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(Lam(Tup((S(Var("z")), Var("U"))), App(Var("foo"), Tup((N, Var("y"))))))), NuFunDef(None, boo, N, Nil, L(Lam(Tup((S(Var("z")), Var("W"))), Var("z"))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Parent),List((None,TypeName(T)), (None,TypeName(U)), (None,TypeName(V))),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(Int))))),Asc(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))),TypeName(T))))), NuTypeDef(Cls,TypeName(Inner),List((None,TypeName(W))),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((Some(Var(z)),Fld(FldFlags(false,false,false),Var(U))))),App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),Var(y))))))))), NuFunDef(None,Var(boo),None,List(),Left(Lam(Tup(List((Some(Var(z)),Fld(FldFlags(false,false,false),Var(W))))),Var(z)))))))))))) //│ Lifted: //│ TypingUnit { //│ class Parent$1_Inner$2[W,U]([par$Parent$1, y: Int,]) { @@ -148,7 +148,7 @@ class A(x: Int): ({a1: Int} & B & D(x)) { //│ |#class| |B|‹|T|›| |{||}|↵|#class| |C| |{||}|↵|#class| |D|(|y|#:| |Int|)| |{||}|↵|#class| |A|‹|T|,| |U|›|(|x|#:| |Int|)|#:| |(|{|a1|#:| |Int|}| |&| |B|‹|T|›| |&| |D|(|x|)|)| |{|→|#fun| |getA|(||)| |#=| |#new| |C|{|→|#fun| |foo|(|x|#:| |T|)| |#=| |x|←|↵|}|←|↵|}| //│ Parsed: {class B‹T› {}; class C {}; class D(y: Int,) {}; class A‹T, U›(x: Int,): {a1: Int} & B[T] & D[x] {fun getA = () => new C { ‹fun foo = (x: T,) => x› }}} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(N -> TypeName("T")), N, N, N, Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("C"), Ls(), N, N, N, Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("D"), Ls(), S(Tup((S(Var("y")), Var("Int")))), N, N, Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("A"), Ls(N -> TypeName("T"), N -> TypeName("U")), S(Tup((S(Var("x")), Var("Int")))), N, S(Inter(Inter(Record(a1: Fld(N, TypeName("Int"))), AppliedType(TypeName("B"), TypeName("T") :: Nil)), AppliedType(TypeName("D"), TypeName("x") :: Nil))), Ls(), N, N, TypingUnit(NuFunDef(None, getA, N, Nil, L(Lam(Tup(), Rft(NuNew(Var("C")), TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup((S(Var("x")), Var("T"))), Var("x")))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(B),List((None,TypeName(T))),None,None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(C),List(),None,None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(D),List(),Some(Tup(List((Some(Var(y)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(A),List((None,TypeName(T)), (None,TypeName(U))),Some(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(Int)))))),None,Some(Inter(Inter(Record(List((Var(a1),Field(None,TypeName(Int))))),AppliedType(TypeName(B),List(TypeName(T)))),AppliedType(TypeName(D),List(TypeName(x))))),List(),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(Lam(Tup(List()),Rft(NuNew(Var(C)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(T))))),Var(x))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class B$1[T]([]) {} @@ -170,7 +170,7 @@ class A(x: Int) extends {a1: Int}, B, D(x){ //│ |#class| |B|‹|T|›| |{||}|↵|#class| |C| |{||}|↵|#class| |D|(|y|#:| |Int|)| |{||}|↵|#class| |A|‹|T|,| |U|›|(|x|#:| |Int|)| |#extends| |{|a1|#:| |Int|}|,| |B|‹|T|›|,| |D|(|x|)|{|→|#fun| |getA|(||)| |#=| |#new| |C|{|→|#fun| |foo|(|x|)| |#=| |x|←|↵|}|←|↵|}| //│ Parsed: {class B‹T› {}; class C {}; class D(y: Int,) {}; class A‹T, U›(x: Int,): '{' {a1: Int} '}', B‹T›, D(x,) {fun getA = () => new C { ‹fun foo = (x,) => x› }}} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(N -> TypeName("T")), N, N, N, Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("C"), Ls(), N, N, N, Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("D"), Ls(), S(Tup((S(Var("y")), Var("Int")))), N, N, Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("A"), Ls(N -> TypeName("T"), N -> TypeName("U")), S(Tup((S(Var("x")), Var("Int")))), N, N, Ls(Bra(rcd = true, Rcd(Var("a1") = Var("Int"))), TyApp(Var("B"), List(TypeName(T))), App(Var("D"), Tup((N, Var("x"))))), N, N, TypingUnit(NuFunDef(None, getA, N, Nil, L(Lam(Tup(), Rft(NuNew(Var("C")), TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("x"))), Var("x")))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(B),List((None,TypeName(T))),None,None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(C),List(),None,None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(D),List(),Some(Tup(List((Some(Var(y)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(A),List((None,TypeName(T)), (None,TypeName(U))),Some(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(Bra(true,Rcd(List((Var(a1),Fld(FldFlags(false,false,false),Var(Int)))))), TyApp(Var(B),List(TypeName(T))), App(Var(D),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))))),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(Lam(Tup(List()),Rft(NuNew(Var(C)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Var(x))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class B$1[T]([]) {} @@ -190,7 +190,7 @@ class Child(x): ({ age: T } & { name: String}) { //│ |#class| |Child|‹|T|,| |U|›|(|x|)|#:| |(|{| |age|#:| |T| |}| |&| |{| |name|#:| |String|}|)| |{|→|#class| |Inner|{|→|#fun| |foo| |#=| |age|←|↵|}|↵|#fun| |bar| |#=| |age|↵|#fun| |boo| |#=| |#new| |Inner|←|↵|}| //│ Parsed: {class Child‹T, U›(x,): {age: T} & {name: String} {class Inner {fun foo = age}; fun bar = age; fun boo = new Inner}} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("Child"), Ls(N -> TypeName("T"), N -> TypeName("U")), S(Tup((N, Var("x")))), N, S(Inter(Record(age: Fld(N, TypeName("T"))), Record(name: Fld(N, TypeName("String"))))), Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("Inner"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Var("age"))))), NuFunDef(None, bar, N, Nil, L(Var("age"))), NuFunDef(None, boo, N, Nil, L(NuNew(Var("Inner"))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Child),List((None,TypeName(T)), (None,TypeName(U))),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,Some(Inter(Record(List((Var(age),Field(None,TypeName(T))))),Record(List((Var(name),Field(None,TypeName(String))))))),List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(Inner),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Var(age)))))), NuFunDef(None,Var(bar),None,List(),Left(Var(age))), NuFunDef(None,Var(boo),None,List(),Left(NuNew(Var(Inner))))))))) //│ Lifted: //│ TypingUnit { //│ class Child$1_Inner$2([par$Child$1, age,]) {fun foo = () => (this).age} @@ -213,7 +213,7 @@ new A(0) { //│ |#class| |A|(|x|#:| |Int|)| |{|→|#fun| |getA|#:| |Int| |#=| |0|↵|#fun| |getA1| |#=| |1|←|↵|}|↵|#new| |A|(|0|)| |{|→|#fun| |getA| |#=| |3|↵|#fun| |getA2| |#=| |2|←|↵|}| //│ Parsed: {class A(x: Int,) {fun getA = 0 : Int; fun getA1 = 1}; (new A)(0,) { ‹fun getA = 3; fun getA2 = 2› }} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((S(Var("x")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, getA, N, Nil, L(Asc(IntLit(0), TypeName("Int")))), NuFunDef(None, getA1, N, Nil, L(IntLit(1))))), Rft(App(NuNew(Var("A")), Tup((N, IntLit(0)))), TypingUnit(NuFunDef(None, getA, N, Nil, L(IntLit(3))), NuFunDef(None, getA2, N, Nil, L(IntLit(2)))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(Asc(IntLit(0),TypeName(Int)))), NuFunDef(None,Var(getA1),None,List(),Left(IntLit(1)))))), Rft(App(NuNew(Var(A)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))),TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(IntLit(3))), NuFunDef(None,Var(getA2),None,List(),Left(IntLit(2)))))))) //│ Lifted: //│ TypingUnit { //│ class A$1([x: Int,]) {fun getA = () => 0 : Int; fun getA1 = () => 1} @@ -234,7 +234,7 @@ new A(1) { //│ |#class| |A|(|x|)| |{|→|#class| |B|(|y|)| |{| |}|←|↵|}|↵|#new| |A|(|1|)| |{|→|#fun| |getB| |#=| |#new| |B|(|2|)|{|→|#fun| |getB| |#=| |#new| |B|(|3|)|←|↵|}|←|↵|}| //│ Parsed: {class A(x,) {class B(y,) {}}; (new A)(1,) { ‹fun getB = (new B)(2,) { ‹fun getB = (new B)(3,)› }› }} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), S(Tup((N, Var("y")))), N, N, Ls(), N, N, TypingUnit()))), Rft(App(NuNew(Var("A")), Tup((N, IntLit(1)))), TypingUnit(NuFunDef(None, getB, N, Nil, L(Rft(App(NuNew(Var("B")), Tup((N, IntLit(2)))), TypingUnit(NuFunDef(None, getB, N, Nil, L(App(NuNew(Var("B")), Tup((N, IntLit(3))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))),None,None,List(),None,None,TypingUnit(List()))))), Rft(App(NuNew(Var(A)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))),TypingUnit(List(NuFunDef(None,Var(getB),None,List(),Left(Rft(App(NuNew(Var(B)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))),TypingUnit(List(NuFunDef(None,Var(getB),None,List(),Left(App(NuNew(Var(B)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(3)))))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1, y,]) {} @@ -267,7 +267,7 @@ new B{ //│ |#class| |A| |{|→|#fun| |getA| |#=| |0|↵|#fun| |funcA| |#=| |10|←|↵|}|↵|#class| |B|#:| |A|{|→|#fun| |getA| |#=| |1|↵|#fun| |funcB| |#=| |11|←|↵|}|↵|#new| |A|↵|#new| |B|↵|#fun| |f|(|x|)| |#=| |#if| |x| |is| |A| |#then| |0| |#else| |1|↵|f|(|#new| |A|{|→|#fun| |getA| |#=| |2|←|↵|}|)|↵|#new| |B|{|→|#fun| |getA| |#=| |funcB|←|↵|}| //│ Parsed: {class A {fun getA = 0; fun funcA = 10}; class B: A {fun getA = 1; fun funcB = 11}; new A; new B; fun f = (x,) => if (is(x, A,)) then 0 else 1; f(new A { ‹fun getA = 2› },); new B { ‹fun getA = funcB› }} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, getA, N, Nil, L(IntLit(0))), NuFunDef(None, funcA, N, Nil, L(IntLit(10))))), NuTypeDef(Cls, TypeName("B"), Ls(), N, N, S(TypeName("A")), Ls(), N, N, TypingUnit(NuFunDef(None, getA, N, Nil, L(IntLit(1))), NuFunDef(None, funcB, N, Nil, L(IntLit(11))))), NuNew(Var("A")), NuNew(Var("B")), NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x"))), If(IfThen(App(Var("is"), Tup((N, Var("x")), (N, Var("A")))), IntLit(0), Some(IntLit(1)))))), App(Var("f"), Tup((N, Rft(NuNew(Var("A")), TypingUnit(NuFunDef(None, getA, N, Nil, L(IntLit(2)))))))), Rft(NuNew(Var("B")), TypingUnit(NuFunDef(None, getA, N, Nil, L(Var("funcB")))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(IntLit(0))), NuFunDef(None,Var(funcA),None,List(),Left(IntLit(10)))))), NuTypeDef(Cls,TypeName(B),List(),None,None,Some(TypeName(A)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(IntLit(1))), NuFunDef(None,Var(funcB),None,List(),Left(IntLit(11)))))), NuNew(Var(A)), NuNew(Var(B)), NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),If(IfThen(App(Var(is),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(A)))))),IntLit(0)),Some(IntLit(1)))))), App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(IntLit(2))))))))))), Rft(NuNew(Var(B)),TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(Var(funcB)))))))) //│ Lifted: //│ TypingUnit { //│ class A$1([]) {fun getA = () => 0; fun funcA = () => 10} @@ -306,7 +306,7 @@ class A{ //│ |#class| |A|{|→|#class| |B|{|→|#fun| |funB| |#=| |1|↵|#fun| |foo| |#=| |100|←|↵|}|↵|#class| |C|#:| |B|{|→|#fun| |funC| |#=| |2|↵|#fun| |foo| |#=| |1000|←|↵|}|↵|#class| |D|{|→|#fun| |funD| |#=| |3|↵|#fun| |foo| |#=| |10000| |↵|#class| |E|#:| |C|{|→|#fun| |funE| |#=| |4|↵|#fun| |foo| |#=| |100000|←|↵|}|↵|#class| |F|#:| |E|{|→|#fun| |funF| |#=| |5|↵|#fun| |foo| |#=| |1000000|←|↵|}|←|↵|}|←|↵|}| //│ Parsed: {class A {class B {fun funB = 1; fun foo = 100}; class C: B {fun funC = 2; fun foo = 1000}; class D {fun funD = 3; fun foo = 10000; class E: C {fun funE = 4; fun foo = 100000}; class F: E {fun funF = 5; fun foo = 1000000}}}} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, funB, N, Nil, L(IntLit(1))), NuFunDef(None, foo, N, Nil, L(IntLit(100))))), NuTypeDef(Cls, TypeName("C"), Ls(), N, N, S(TypeName("B")), Ls(), N, N, TypingUnit(NuFunDef(None, funC, N, Nil, L(IntLit(2))), NuFunDef(None, foo, N, Nil, L(IntLit(1000))))), NuTypeDef(Cls, TypeName("D"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, funD, N, Nil, L(IntLit(3))), NuFunDef(None, foo, N, Nil, L(IntLit(10000))), NuTypeDef(Cls, TypeName("E"), Ls(), N, N, S(TypeName("C")), Ls(), N, N, TypingUnit(NuFunDef(None, funE, N, Nil, L(IntLit(4))), NuFunDef(None, foo, N, Nil, L(IntLit(100000))))), NuTypeDef(Cls, TypeName("F"), Ls(), N, N, S(TypeName("E")), Ls(), N, N, TypingUnit(NuFunDef(None, funF, N, Nil, L(IntLit(5))), NuFunDef(None, foo, N, Nil, L(IntLit(1000000)))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(funB),None,List(),Left(IntLit(1))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(100)))))), NuTypeDef(Cls,TypeName(C),List(),None,None,Some(TypeName(B)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(funC),None,List(),Left(IntLit(2))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(1000)))))), NuTypeDef(Cls,TypeName(D),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(funD),None,List(),Left(IntLit(3))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(10000))), NuTypeDef(Cls,TypeName(E),List(),None,None,Some(TypeName(C)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(funE),None,List(),Left(IntLit(4))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(100000)))))), NuTypeDef(Cls,TypeName(F),List(),None,None,Some(TypeName(E)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(funF),None,List(),Left(IntLit(5))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(1000000)))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1,]) {fun funB = () => 1; fun foo = () => 100} @@ -349,7 +349,7 @@ class A{ //│ |#class| |A|{|→|#class| |B|{|→|#fun| |funB| |#=| |1|↵|#fun| |foo| |#=| |100|←|↵|}|↵|#class| |C|#:| |B|{|→|#fun| |funC| |#=| |2|↵|#fun| |foo| |#=| |1000|↵|#fun| |getB| |#=| |#new| |B|←|↵|}|↵|#class| |D|{|→|#fun| |funD| |#=| |3|↵|#fun| |foo| |#=| |10000| |↵|#class| |E|#:| |C|{|→|#fun| |funE| |#=| |4|↵|#fun| |foo| |#=| |100000|↵|#fun| |getD| |#=| |#new| |D|←|↵|}|↵|#class| |F|#:| |E|{|→|#fun| |funF| |#=| |5|↵|#fun| |foo| |#=| |1000000|↵|#fun| |getE| |#=| |#new| |E|{|→|#fun| |foo| |#=| |0|←|↵|}|←|↵|}|←|↵|}|←|↵|}| //│ Parsed: {class A {class B {fun funB = 1; fun foo = 100}; class C: B {fun funC = 2; fun foo = 1000; fun getB = new B}; class D {fun funD = 3; fun foo = 10000; class E: C {fun funE = 4; fun foo = 100000; fun getD = new D}; class F: E {fun funF = 5; fun foo = 1000000; fun getE = new E { ‹fun foo = 0› }}}}} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, funB, N, Nil, L(IntLit(1))), NuFunDef(None, foo, N, Nil, L(IntLit(100))))), NuTypeDef(Cls, TypeName("C"), Ls(), N, N, S(TypeName("B")), Ls(), N, N, TypingUnit(NuFunDef(None, funC, N, Nil, L(IntLit(2))), NuFunDef(None, foo, N, Nil, L(IntLit(1000))), NuFunDef(None, getB, N, Nil, L(NuNew(Var("B")))))), NuTypeDef(Cls, TypeName("D"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, funD, N, Nil, L(IntLit(3))), NuFunDef(None, foo, N, Nil, L(IntLit(10000))), NuTypeDef(Cls, TypeName("E"), Ls(), N, N, S(TypeName("C")), Ls(), N, N, TypingUnit(NuFunDef(None, funE, N, Nil, L(IntLit(4))), NuFunDef(None, foo, N, Nil, L(IntLit(100000))), NuFunDef(None, getD, N, Nil, L(NuNew(Var("D")))))), NuTypeDef(Cls, TypeName("F"), Ls(), N, N, S(TypeName("E")), Ls(), N, N, TypingUnit(NuFunDef(None, funF, N, Nil, L(IntLit(5))), NuFunDef(None, foo, N, Nil, L(IntLit(1000000))), NuFunDef(None, getE, N, Nil, L(Rft(NuNew(Var("E")), TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(0)))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(funB),None,List(),Left(IntLit(1))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(100)))))), NuTypeDef(Cls,TypeName(C),List(),None,None,Some(TypeName(B)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(funC),None,List(),Left(IntLit(2))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(1000))), NuFunDef(None,Var(getB),None,List(),Left(NuNew(Var(B))))))), NuTypeDef(Cls,TypeName(D),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(funD),None,List(),Left(IntLit(3))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(10000))), NuTypeDef(Cls,TypeName(E),List(),None,None,Some(TypeName(C)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(funE),None,List(),Left(IntLit(4))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(100000))), NuFunDef(None,Var(getD),None,List(),Left(NuNew(Var(D))))))), NuTypeDef(Cls,TypeName(F),List(),None,None,Some(TypeName(E)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(funF),None,List(),Left(IntLit(5))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(1000000))), NuFunDef(None,Var(getE),None,List(),Left(Rft(NuNew(Var(E)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(0))))))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1,]) {fun funB = () => 1; fun foo = () => 100} @@ -384,7 +384,7 @@ new A //│ |#class| |A|{|→|#class| |B|{|→|#fun| |foo| |#=| |1|←|↵|}|↵|#fun| |bar| |#=| |#new| |B|←|↵|}|↵|#new| |A| //│ Parsed: {class A {class B {fun foo = 1}; fun bar = new B}; new A} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(1))))), NuFunDef(None, bar, N, Nil, L(NuNew(Var("B")))))), NuNew(Var("A"))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(1)))))), NuFunDef(None,Var(bar),None,List(),Left(NuNew(Var(B))))))), NuNew(Var(A)))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1,]) {fun foo = () => 1} @@ -409,7 +409,7 @@ let x = new A{ //│ |#class| |A|(|x|)| |{|→|#fun| |foo| |#=| |0|↵|#fun| |bar| |#=| |x|←|↵|}|↵|#let| |x| |#=| |#new| |A|{|→|#fun| |foo| |#=| |1|↵|#fun| |newFun| |#=| |2|↵|#fun| |bar| |#=| |#new| |A|(|foo|)|{|→|#fun| |foo| |#=| |bar| |+| |1|↵|#fun| |bar2| |#=| |newFun| |+| |1|←|↵|}|←|↵|}| //│ Parsed: {class A(x,) {fun foo = 0; fun bar = x}; let x = new A { ‹fun foo = 1; fun newFun = 2; fun bar = (new A)(foo,) { ‹fun foo = +(bar, 1,); fun bar2 = +(newFun, 1,)› }› }} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(0))), NuFunDef(None, bar, N, Nil, L(Var("x"))))), NuFunDef(Some(false), x, N, Nil, L(Rft(NuNew(Var("A")), TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(1))), NuFunDef(None, newFun, N, Nil, L(IntLit(2))), NuFunDef(None, bar, N, Nil, L(Rft(App(NuNew(Var("A")), Tup((N, Var("foo")))), TypingUnit(NuFunDef(None, foo, N, Nil, L(App(Var("+"), Tup((N, Var("bar")), (N, IntLit(1)))))), NuFunDef(None, bar2, N, Nil, L(App(Var("+"), Tup((N, Var("newFun")), (N, IntLit(1))))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(0))), NuFunDef(None,Var(bar),None,List(),Left(Var(x)))))), NuFunDef(Some(false),Var(x),None,List(),Left(Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(1))), NuFunDef(None,Var(newFun),None,List(),Left(IntLit(2))), NuFunDef(None,Var(bar),None,List(),Left(Rft(App(NuNew(Var(A)),Tup(List((None,Fld(FldFlags(false,false,false),Var(foo)))))),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(bar))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))))), NuFunDef(None,Var(bar2),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(newFun))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1([x,]) {fun foo = () => 0; fun bar = () => (this).x} @@ -437,7 +437,7 @@ new A{ //│ |#class| |A| |{||}|↵|#new| |A|{|→|#fun| |foo| |#=| |1|↵|#fun| |bar| |#=| |#new| |A|{|→|#fun| |foo1| |#=| |foo|↵|#fun| |bar1| |#=| |#new| |A|{|→|#fun| |foo2| |#=| |foo|↵|#fun| |bar2| |#=| |#new| |A|{|→|#fun| |foo3| |#=| |foo|↵|#fun| |bar3| |#=| |#new| |A|{|→|#fun| |foo4| |#=| |foo|↵|#fun| |bar4| |#=| |0|←|↵|}|←|↵|}|←|↵|}|←|↵|}|←|↵|}| //│ Parsed: {class A {}; new A { ‹fun foo = 1; fun bar = new A { ‹fun foo1 = foo; fun bar1 = new A { ‹fun foo2 = foo; fun bar2 = new A { ‹fun foo3 = foo; fun bar3 = new A { ‹fun foo4 = foo; fun bar4 = 0› }› }› }› }› }} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit()), Rft(NuNew(Var("A")), TypingUnit(NuFunDef(None, foo, N, Nil, L(IntLit(1))), NuFunDef(None, bar, N, Nil, L(Rft(NuNew(Var("A")), TypingUnit(NuFunDef(None, foo1, N, Nil, L(Var("foo"))), NuFunDef(None, bar1, N, Nil, L(Rft(NuNew(Var("A")), TypingUnit(NuFunDef(None, foo2, N, Nil, L(Var("foo"))), NuFunDef(None, bar2, N, Nil, L(Rft(NuNew(Var("A")), TypingUnit(NuFunDef(None, foo3, N, Nil, L(Var("foo"))), NuFunDef(None, bar3, N, Nil, L(Rft(NuNew(Var("A")), TypingUnit(NuFunDef(None, foo4, N, Nil, L(Var("foo"))), NuFunDef(None, bar4, N, Nil, L(IntLit(0)))))))))))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List())), Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(1))), NuFunDef(None,Var(bar),None,List(),Left(Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(foo1),None,List(),Left(Var(foo))), NuFunDef(None,Var(bar1),None,List(),Left(Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(foo2),None,List(),Left(Var(foo))), NuFunDef(None,Var(bar2),None,List(),Left(Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(foo3),None,List(),Left(Var(foo))), NuFunDef(None,Var(bar3),None,List(),Left(Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(foo4),None,List(),Left(Var(foo))), NuFunDef(None,Var(bar4),None,List(),Left(IntLit(0)))))))))))))))))))))))))))) //│ Lifted: //│ TypingUnit {class A$1([]) {}; Code(List(new A$1([]) {}))} //│ diff --git a/compiler/shared/test/diff/LifterBlks.mls b/compiler/shared/test/diff/LifterBlks.mls index b053241fd..f5e52e146 100644 --- a/compiler/shared/test/diff/LifterBlks.mls +++ b/compiler/shared/test/diff/LifterBlks.mls @@ -7,7 +7,7 @@ fun foo = //│ |#fun| |foo| |#=|→|print|(|"ok"|)|↵|print|(|"ko"|)|←| //│ Parsed: {fun foo = {print("ok",); print("ko",)}} //│ Parsed: -//│ TypingUnit(NuFunDef(None, foo, N, Nil, L(Blk(App(Var("print"), Tup((N, StrLit(ok)))), App(Var("print"), Tup((N, StrLit(ko)))))))) +//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Blk(List(App(Var(print),Tup(List((None,Fld(FldFlags(false,false,false),StrLit(ok)))))), App(Var(print),Tup(List((None,Fld(FldFlags(false,false,false),StrLit(ko)))))))))))) //│ Lifted: //│ TypingUnit {fun foo$1 = () => {print("ok",); print("ko",)}} //│ @@ -19,7 +19,7 @@ class A{ //│ |#class| |A|{|→|#class| |B| |{||}|↵|#fun| |foo|(|x|#:| |B|)| |#=| |(|x| |#:| |B|)|←|↵|}| //│ Parsed: {class A {class B {}; fun foo = (x: B,) => '(' x : B ')'}} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit()), NuFunDef(None, foo, N, Nil, L(Lam(Tup((S(Var("x")), Var("B"))), Bra(rcd = false, Asc(Var("x"), TypeName("B"))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List())), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(B))))),Bra(false,Asc(Var(x),TypeName(B))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1,]) {} @@ -41,7 +41,7 @@ fun foo = //│ |#fun| |foo| |#=|→|#let| |local|(|x|)| |#=|→|#class| |Foo| |{|→|#fun| |bar| |#=| |x| |+| |1|←|↵|}|↵|Foo|(||)|.bar|←|↵|print| |#of| |local|(|0|)| |+| |local|(|1|)|↵|print| |#of| |(|local| |#of| |0|)| |+| |local| |#of| |1|↵|#fun| |tmp| |#=| |1|↵|print| |#of| |local| |#of| |0| |+| |local| |#of| |1|↵|#fun| |tmp| |#=| |2|←| //│ Parsed: {fun foo = {let local = (x,) => {class Foo {fun bar = +(x, 1,)}; (Foo()).bar}; print(+(local(0,), local(1,),),); print(+('(' local(0,) ')', local(1,),),); fun tmp = 1; print(local(+(0, local(1,),),),); fun tmp = 2}} //│ Parsed: -//│ TypingUnit(NuFunDef(None, foo, N, Nil, L(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, IntLit(1)))))))), Sel(App(Var("Foo"), Tup()), bar))))), App(Var("print"), Tup((N, App(Var("+"), Tup((N, App(Var("local"), Tup((N, IntLit(0))))), (N, App(Var("local"), Tup((N, IntLit(1)))))))))), App(Var("print"), Tup((N, App(Var("+"), Tup((N, Bra(rcd = false, App(Var("local"), Tup((N, IntLit(0)))))), (N, App(Var("local"), Tup((N, IntLit(1)))))))))), NuFunDef(None, tmp, N, Nil, L(IntLit(1))), App(Var("print"), Tup((N, App(Var("local"), Tup((N, App(Var("+"), Tup((N, IntLit(0)), (N, App(Var("local"), Tup((N, IntLit(1))))))))))))), NuFunDef(None, tmp, N, Nil, L(IntLit(2))))))) +//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(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),IntLit(1))))))))))), Sel(App(Var(Foo),Tup(List())),Var(bar))))))), App(Var(print),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(local),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))))), (None,Fld(FldFlags(false,false,false),App(Var(local),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))))))))))))), App(Var(print),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Bra(false,App(Var(local),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0))))))))), (None,Fld(FldFlags(false,false,false),App(Var(local),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))))))))))))), NuFunDef(None,Var(tmp),None,List(),Left(IntLit(1))), App(Var(print),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(local),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0))), (None,Fld(FldFlags(false,false,false),App(Var(local),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))))))))))))))))))))), NuFunDef(None,Var(tmp),None,List(),Left(IntLit(2))))))))) //│ Lifted: //│ TypingUnit { //│ class Foo$1([x,]) {fun bar = () => +((this).x, 1,)} @@ -57,7 +57,7 @@ f(0) //│ |#class| |A|(|y|)|{||}|↵|#let| |f| |#=| |x| |#=>| |#new| |A|(|0|)|{|#fun| |bar| |#=| |x|+|y|}|↵|f|(|0|)| //│ Parsed: {class A(y,) {}; let f = (x,) => (new A)(0,) { ‹fun bar = +(x, y,)› }; f(0,)} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("y")))), N, N, Ls(), N, N, TypingUnit()), NuFunDef(Some(false), f, N, Nil, L(Lam(Tup((N, Var("x"))), Rft(App(NuNew(Var("A")), Tup((N, IntLit(0)))), TypingUnit(NuFunDef(None, bar, N, Nil, L(App(Var("+"), Tup((N, Var("x")), (N, Var("y"))))))))))), App(Var("f"), Tup((N, IntLit(0))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))),None,None,List(),None,None,TypingUnit(List())), NuFunDef(Some(false),Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Rft(App(NuNew(Var(A)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))),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),Var(y)))))))))))))), App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))))) //│ Lifted: //│ TypingUnit { //│ class A$1([y,]) {} @@ -80,7 +80,7 @@ class A(x){ //│ |#class| |A|(|x|)|{|→|#fun| |w| |#=| |x|↵|#fun| |foo|(|y|)| |#=| |→|#class| |B|(|z|)|{|→|#fun| |bar| |#=| |x|+|y|+|z|←|↵|}|↵|#new| |B|(|0|)|{|→|#fun| |bar| |#=| |w|+|y|+|z|←|↵|}|←|←|↵|}| //│ Parsed: {class A(x,) {fun w = x; fun foo = (y,) => {class B(z,) {fun bar = +(+(x, y,), z,)}; (new B)(0,) { ‹fun bar = +(+(w, y,), z,)› }}}} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, w, N, Nil, L(Var("x"))), NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("y"))), Blk(NuTypeDef(Cls, TypeName("B"), Ls(), S(Tup((N, Var("z")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(App(Var("+"), Tup((N, App(Var("+"), Tup((N, Var("x")), (N, Var("y"))))), (N, Var("z")))))))), Rft(App(NuNew(Var("B")), Tup((N, IntLit(0)))), TypingUnit(NuFunDef(None, bar, N, Nil, L(App(Var("+"), Tup((N, App(Var("+"), Tup((N, Var("w")), (N, Var("y"))))), (N, Var("z"))))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(w),None,List(),Left(Var(x))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(y))))),Blk(List(NuTypeDef(Cls,TypeName(B),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(z)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))))), (None,Fld(FldFlags(false,false,false),Var(z))))))))))), Rft(App(NuNew(Var(B)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))),TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(w))), (None,Fld(FldFlags(false,false,false),Var(y)))))))), (None,Fld(FldFlags(false,false,false),Var(z))))))))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1, z, y,]) { @@ -111,7 +111,7 @@ fun f(x,y,z) = //│ |#fun| |f|(|x|,|y|,|z|)| |#=| |→|#class| |A|{|→|#fun| |foo| |#=| |#new| |B|↵|#fun| |bar1| |#=| |x|←|↵|}|↵|#class| |B|{|→|#fun| |foo| |#=| |#new| |A|↵|#fun| |bar2| |#=| |y|←|↵|}|↵|#class| |C| |#extends| |A|,| |B| |{|→|#fun| |bar| |#=| |bar1| |+| |bar2|←|↵|}|←| //│ Parsed: {fun f = (x, y, z,) => {class A {fun foo = new B; fun bar1 = x}; class B {fun foo = new A; fun bar2 = y}; class C: A, B {fun bar = +(bar1, bar2,)}}} //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x")), (N, Var("y")), (N, Var("z"))), Blk(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(NuNew(Var("B")))), NuFunDef(None, bar1, N, Nil, L(Var("x"))))), NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(NuNew(Var("A")))), NuFunDef(None, bar2, N, Nil, L(Var("y"))))), NuTypeDef(Cls, TypeName("C"), Ls(), N, N, N, Ls(Var("A"), Var("B")), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(App(Var("+"), Tup((N, Var("bar1")), (N, Var("bar2"))))))))))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y))), (None,Fld(FldFlags(false,false,false),Var(z))))),Blk(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(NuNew(Var(B)))), NuFunDef(None,Var(bar1),None,List(),Left(Var(x)))))), NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(NuNew(Var(A)))), NuFunDef(None,Var(bar2),None,List(),Left(Var(y)))))), NuTypeDef(Cls,TypeName(C),List(),None,None,None,List(Var(A), Var(B)),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(bar1))), (None,Fld(FldFlags(false,false,false),Var(bar2)))))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1([x, y,]) { @@ -142,7 +142,7 @@ fun f(x,y,z) = //│ |#fun| |f|(|x|,|y|,|z|)| |#=| |→|#class| |C|{|→|#class| |A|{|→|#fun| |foo| |#=| |#new| |B|↵|#fun| |bar1| |#=| |x|←|↵|}|↵|#class| |B|{|→|#fun| |foo| |#=| |#new| |A|↵|#fun| |bar2| |#=| |y|←|↵|}|↵|#fun| |boo| |#=| |(|#new| |A|)|.bar1| |+| |B|(||)|.bar2| |+| |z|←|↵|}|←| //│ Parsed: {fun f = (x, y, z,) => {class C {class A {fun foo = new B; fun bar1 = x}; class B {fun foo = new A; fun bar2 = y}; fun boo = +(+(('(' new A ')').bar1, (B()).bar2,), z,)}}} //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x")), (N, Var("y")), (N, Var("z"))), Blk(NuTypeDef(Cls, TypeName("C"), 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(NuNew(Var("B")))), NuFunDef(None, bar1, N, Nil, L(Var("x"))))), NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(NuNew(Var("A")))), NuFunDef(None, bar2, N, Nil, L(Var("y"))))), NuFunDef(None, boo, N, Nil, L(App(Var("+"), Tup((N, App(Var("+"), Tup((N, Sel(Bra(rcd = false, NuNew(Var("A"))), bar1)), (N, Sel(App(Var("B"), Tup()), bar2))))), (N, Var("z"))))))))))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y))), (None,Fld(FldFlags(false,false,false),Var(z))))),Blk(List(NuTypeDef(Cls,TypeName(C),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(NuNew(Var(B)))), NuFunDef(None,Var(bar1),None,List(),Left(Var(x)))))), NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(NuNew(Var(A)))), NuFunDef(None,Var(bar2),None,List(),Left(Var(y)))))), NuFunDef(None,Var(boo),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Sel(Bra(false,NuNew(Var(A))),Var(bar1)))), (None,Fld(FldFlags(false,false,false),Sel(App(Var(B),Tup(List())),Var(bar2))))))))), (None,Fld(FldFlags(false,false,false),Var(z)))))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class C$1_A$2([par$C$1,]) { @@ -168,7 +168,7 @@ fun f(y) = //│ |#fun| |f|(|y|)| |#=|→|#let| |g|(|x|)| |#=| |x| |+| |y| |+| |1|↵|#class| |Foo|(|x|)| |{|→|#fun| |h| |#=| |g|(|x|)|←|↵|}|←| //│ Parsed: {fun f = (y,) => {let g = (x,) => +(+(x, y,), 1,); class Foo(x,) {fun h = g(x,)}}} //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("y"))), Blk(NuFunDef(Some(false), g, N, Nil, L(Lam(Tup((N, Var("x"))), App(Var("+"), Tup((N, App(Var("+"), Tup((N, Var("x")), (N, Var("y"))))), (N, IntLit(1))))))), NuTypeDef(Cls, TypeName("Foo"), Ls(), S(Tup((N, Var("x")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, h, N, Nil, L(App(Var("g"), Tup((N, Var("x"))))))))))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(y))))),Blk(List(NuFunDef(Some(false),Var(g),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))))), NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(h),None,List(),Left(App(Var(g),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class Foo$1([x, y,]) {fun h = () => g$2((this).x, y,)} @@ -180,7 +180,7 @@ fun f(y) = //│ | |Foo|(|1|)|.h| //│ Parsed: {(Foo(1,)).h} //│ Parsed: -//│ TypingUnit(Sel(App(Var("Foo"), Tup((N, IntLit(1)))), h)) +//│ TypingUnit(List(Sel(App(Var(Foo),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))),Var(h)))) //│ Lifted: //│ TypingUnit {Code(List((Foo(1,)).h))} //│ @@ -188,7 +188,7 @@ fun f(y) = //│ | |Foo|(|x|)|.h| //│ Parsed: {(Foo(x,)).h} //│ Parsed: -//│ TypingUnit(Sel(App(Var("Foo"), Tup((N, Var("x")))), h)) +//│ TypingUnit(List(Sel(App(Var(Foo),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),Var(h)))) //│ Lifted: //│ TypingUnit {Code(List((Foo(x,)).h))} //│ @@ -204,7 +204,7 @@ fun f(x) = //│ |#fun| |f|(|x|)| |#=|→|#let| |g|(|x|)| |#=| |→|#let| |h|(|x|)| |#=| |x| |+| |2|↵|Foo|(|h|(|x|)|,| |x|)|.bar|←|↵|#class| |Foo|(|x|,| |y|)| |{|→|#fun| |bar| |#=| |g|(|x|)|+|y|←|↵|}|↵|Foo|(|x|,| |x|)|.bar|←| //│ Parsed: {fun f = (x,) => {let g = (x,) => {let h = (x,) => +(x, 2,); (Foo(h(x,), x,)).bar}; class Foo(x, y,) {fun bar = +(g(x,), y,)}; (Foo(x, x,)).bar}} //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(NuFunDef(Some(false), g, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(NuFunDef(Some(false), h, N, Nil, L(Lam(Tup((N, Var("x"))), App(Var("+"), Tup((N, Var("x")), (N, IntLit(2))))))), Sel(App(Var("Foo"), Tup((N, App(Var("h"), Tup((N, Var("x"))))), (N, Var("x")))), bar))))), NuTypeDef(Cls, TypeName("Foo"), Ls(), S(Tup((N, Var("x")), (N, Var("y")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(App(Var("+"), Tup((N, App(Var("g"), Tup((N, Var("x"))))), (N, Var("y")))))))), Sel(App(Var("Foo"), Tup((N, Var("x")), (N, Var("x")))), bar)))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(NuFunDef(Some(false),Var(g),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(NuFunDef(Some(false),Var(h),None,List(),Left(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(2))))))))), Sel(App(Var(Foo),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(h),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))), (None,Fld(FldFlags(false,false,false),Var(x)))))),Var(bar))))))), NuTypeDef(Cls,TypeName(Foo),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(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(g),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))), (None,Fld(FldFlags(false,false,false),Var(y))))))))))), Sel(App(Var(Foo),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(x)))))),Var(bar))))))))) //│ Lifted: //│ TypingUnit { //│ class Foo$1([x, y,]) {fun bar = () => +(g$2((this).x,), (this).y,)} @@ -218,7 +218,7 @@ class Foo(x, y) extends Bar(y, x), Baz(x + y) //│ |#class| |Foo|(|x|,| |y|)| |#extends| |Bar|(|y|,| |x|)|,| |Baz|(|x| |+| |y|)| //│ Parsed: {class Foo(x, y,): Bar(y, x,), Baz(+(x, y,),) {}} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("Foo"), Ls(), S(Tup((N, Var("x")), (N, Var("y")))), N, N, Ls(App(Var("Bar"), Tup((N, Var("y")), (N, Var("x")))), App(Var("Baz"), Tup((N, App(Var("+"), Tup((N, Var("x")), (N, Var("y")))))))), N, N, TypingUnit())) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))),None,None,List(App(Var(Bar),Tup(List((None,Fld(FldFlags(false,false,false),Var(y))), (None,Fld(FldFlags(false,false,false),Var(x)))))), App(Var(Baz),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))))))))),None,None,TypingUnit(List())))) //│ Lifted: //│ TypingUnit { //│ class Foo$1([x, y,]): Bar((this).y, (this).x,), Baz(+((this).x, (this).y,),) {} @@ -233,7 +233,7 @@ fun foo(x: T): string = //│ |#fun| |foo|‹|T|,| |U|›|(|x|#:| |T|)|#:| |string| |#=| |→|#class| |A|(|y|)| |#extends| |B|‹|T|›|,| |C|(|y|#:| |U|)| |{|→|#fun| |bar| |#=| |this|←|↵|}|↵|"rua"|←| //│ Parsed: {fun foo = (x: T,) => {class A(y,): B‹T›, C(y: U,) {fun bar = this}; "rua"} : string} //│ Parsed: -//│ TypingUnit(NuFunDef(None, foo, N, TypeName("T") :: TypeName("U") :: Nil, L(Lam(Tup((S(Var("x")), Var("T"))), Asc(Blk(NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((N, Var("y")))), N, N, Ls(TyApp(Var("B"), List(TypeName(T))), App(Var("C"), Tup((S(Var("y")), Var("U"))))), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(Var("this"))))), StrLit(rua)), TypeName("string")))))) +//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(TypeName(T), TypeName(U)),Left(Lam(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(T))))),Asc(Blk(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))),None,None,List(TyApp(Var(B),List(TypeName(T))), App(Var(C),Tup(List((Some(Var(y)),Fld(FldFlags(false,false,false),Var(U))))))),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(Var(this)))))), StrLit(rua))),TypeName(string))))))) //│ Lifted: //│ TypingUnit { //│ class A$1[T,U]([y,]): B‹T›, C(y: U,) {fun bar = () => this} @@ -250,7 +250,7 @@ class A{ //│ |#class| |A|‹|T|›|{|→|#class| |B|{|→|#fun| |f| |#=| |x| |#=>| |y| |#=>| |x|↵|#fun| |g|#:| |T| |#=>| |B| |#=>| |T|←|↵|}|←|↵|}| //│ Parsed: {class A‹T› {class B {fun f = (x,) => (y,) => x; fun g: T -> B -> T}}} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(N -> TypeName("T")), N, N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("B"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x"))), Lam(Tup((N, Var("y"))), Var("x"))))), NuFunDef(None, g, N, Nil, R(PolyType(Ls(), Function(Tuple(N -> Fld(N, TypeName("T"))), Function(Tuple(N -> Fld(N, TypeName("B"))), TypeName("T"))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List((None,TypeName(T))),None,None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(y))))),Var(x))))), NuFunDef(None,Var(g),None,List(),Right(PolyType(List(),Function(Tuple(List((None,Field(None,TypeName(T))))),Function(Tuple(List((None,Field(None,TypeName(B))))),TypeName(T)))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2_Lambda1$1$3([par$A$1_B$2, x,]) {fun apply = (y,) => (this).x} @@ -270,7 +270,7 @@ class Foo{ //│ |#class| |Foo|‹|T|›|{|→|#class| |RectangleBox|#:| |Box|‹|T|›| |&| |{| |breadth|#:| |T| |}|↵|#class| |StackedRectangleBoxes|‹|N|›| |#:| |RectangleBox|‹|T|›| |&| |{| |size|#:| |N| |}|↵|#class| |Bar|#:| |{|any|#:| |RectangleBox| |#=>| |StackedRectangleBoxes|}|←|↵|}| //│ Parsed: {class Foo‹T› {class RectangleBox: Box[T] & {breadth: T} {}; class StackedRectangleBoxes‹N›: RectangleBox[T] & {size: N} {}; class Bar: {any: RectangleBox -> StackedRectangleBoxes} {}}} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("Foo"), Ls(N -> TypeName("T")), N, N, N, Ls(), N, N, TypingUnit(NuTypeDef(Cls, TypeName("RectangleBox"), Ls(), N, N, S(Inter(AppliedType(TypeName("Box"), TypeName("T") :: Nil), Record(breadth: Fld(N, TypeName("T"))))), Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("StackedRectangleBoxes"), Ls(N -> TypeName("N")), N, N, S(Inter(AppliedType(TypeName("RectangleBox"), TypeName("T") :: Nil), Record(size: Fld(N, TypeName("N"))))), Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("Bar"), Ls(), N, N, S(Record(any: Fld(N, Function(Tuple(N -> Fld(N, TypeName("RectangleBox"))), TypeName("StackedRectangleBoxes"))))), Ls(), N, N, TypingUnit())))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Foo),List((None,TypeName(T))),None,None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(RectangleBox),List(),None,None,Some(Inter(AppliedType(TypeName(Box),List(TypeName(T))),Record(List((Var(breadth),Field(None,TypeName(T))))))),List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(StackedRectangleBoxes),List((None,TypeName(N))),None,None,Some(Inter(AppliedType(TypeName(RectangleBox),List(TypeName(T))),Record(List((Var(size),Field(None,TypeName(N))))))),List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(Bar),List(),None,None,Some(Record(List((Var(any),Field(None,Function(Tuple(List((None,Field(None,TypeName(RectangleBox))))),TypeName(StackedRectangleBoxes))))))),List(),None,None,TypingUnit(List()))))))) //│ Lifted: //│ TypingUnit { //│ class Foo$1_RectangleBox$2([par$Foo$1,]) {} @@ -293,7 +293,7 @@ fun ctx(a,b) = //│ |#class| |Func|‹|T|,| |U|›| |{|→|#fun| |apply|#:| |T| |#=>| |U|←|↵|}|↵|#class| |Lambda|‹|T|,| |U|›| |#:| |Func|‹|T|,| |U|›| |{||}|↵|#fun| |ctx|(|a|,|b|)| |#=|→|#fun| |foo|(|f|#:| |Func|,| |x|)| |#=| |→|f|.apply|(|x|)|←|↵|foo|(|#new| |Lambda|{|→|#fun| |apply|(|x|)| |#=| |a|+|x|←|↵|}|,| |b|)|←| //│ Parsed: {class Func‹T, U› {fun apply: T -> U}; class Lambda‹T, U›: Func[T, U] {}; fun ctx = (a, b,) => {fun foo = (f: Func, x,) => {(f).apply(x,)}; foo(new Lambda { ‹fun apply = (x,) => +(a, x,)› }, b,)}} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("Func"), Ls(N -> TypeName("T"), N -> TypeName("U")), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, apply, N, Nil, R(PolyType(Ls(), Function(Tuple(N -> Fld(N, TypeName("T"))), TypeName("U"))))))), NuTypeDef(Cls, TypeName("Lambda"), Ls(N -> TypeName("T"), N -> TypeName("U")), N, N, S(AppliedType(TypeName("Func"), TypeName("T") :: TypeName("U") :: Nil)), Ls(), N, N, TypingUnit()), NuFunDef(None, ctx, N, Nil, L(Lam(Tup((N, Var("a")), (N, Var("b"))), Blk(NuFunDef(None, foo, N, Nil, L(Lam(Tup((S(Var("f")), Var("Func")), (N, Var("x"))), Blk(App(Sel(Var("f"), apply), Tup((N, Var("x")))))))), App(Var("foo"), Tup((N, Rft(NuNew(Var("Lambda")), TypingUnit(NuFunDef(None, apply, N, Nil, L(Lam(Tup((N, Var("x"))), App(Var("+"), Tup((N, Var("a")), (N, Var("x")))))))))), (N, Var("b"))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Func),List((None,TypeName(T)), (None,TypeName(U))),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(apply),None,List(),Right(PolyType(List(),Function(Tuple(List((None,Field(None,TypeName(T))))),TypeName(U)))))))), NuTypeDef(Cls,TypeName(Lambda),List((None,TypeName(T)), (None,TypeName(U))),None,None,Some(AppliedType(TypeName(Func),List(TypeName(T), TypeName(U)))),List(),None,None,TypingUnit(List())), NuFunDef(None,Var(ctx),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),Var(b))))),Blk(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(f)),Fld(FldFlags(false,false,false),Var(Func))), (None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(App(Sel(Var(f),Var(apply)),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),Rft(NuNew(Var(Lambda)),TypingUnit(List(NuFunDef(None,Var(apply),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),Var(x)))))))))))))), (None,Fld(FldFlags(false,false,false),Var(b))))))))))))) //│ Lifted: //│ TypingUnit { //│ class Func$1[T,U]([]) {fun apply = T -> U} @@ -309,7 +309,7 @@ f(MyClass) //│ |#fun| |f|(|T|)| |#=| |→|#new| |T|(||)|←|↵|f|(|MyClass|)| //│ Parsed: {fun f = (T,) => {(new T)()}; f(MyClass,)} //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("T"))), Blk(App(NuNew(Var("T")), Tup()))))), App(Var("f"), Tup((N, Var("MyClass"))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(T))))),Blk(List(App(NuNew(Var(T)),Tup(List()))))))), App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),Var(MyClass)))))))) //│ Lifted: //│ Lifting failed: mlscript.codegen.CodeGenError: Cannot find type T. Class values are not supported in lifter. //│ @@ -322,7 +322,7 @@ class A { //│ |#class| |A| |{|→|#fun| |foo| |#=| |→|#fun| |bar| |#=| |foo|(||)|↵|bar|(||)|←|←|↵|}| //│ Parsed: {class A {fun foo = {fun bar = foo(); bar()}}} //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("A"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Blk(NuFunDef(None, bar, N, Nil, L(App(Var("foo"), Tup()))), App(Var("bar"), Tup()))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Blk(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(foo),Tup(List())))), App(Var(bar),Tup(List()))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1([]) {fun foo = () => {bar$1(this,)}} diff --git a/compiler/shared/test/diff/mono.mls b/compiler/shared/test/diff/mono.mls index 31ec3e212..43422ef6d 100644 --- a/compiler/shared/test/diff/mono.mls +++ b/compiler/shared/test/diff/mono.mls @@ -4,7 +4,7 @@ :mono fun f(x: Int) = if x then 42 else 1337 //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((S(Var("x")), Var("Int"))), If(IfThen(Var("x"), IntLit(42), Some(IntLit(1337))))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(Int))))),If(IfThen(Var(x),IntLit(42)),Some(IntLit(1337)))))))) //│ Lifted: //│ TypingUnit { //│ fun f$1 = (x: Int,) => if (x) then 42 else 1337 @@ -19,7 +19,7 @@ fun f(x: Int) = if x then 42 else 1337 :mono fun foo() = 42 //│ Parsed: -//│ TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup(), IntLit(42))))) +//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List()),IntLit(42)))))) //│ Lifted: //│ TypingUnit {fun foo$1 = () => 42} //│ Mono: @@ -34,7 +34,7 @@ fun foo(x, #b) = if b then x else 1337 let a = foo(42, true) let b = foo(23, false) //│ Parsed: -//│ TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("x")), (N, Var("b"))), If(IfThen(Var("b"), Var("x"), Some(IntLit(1337)))))), NuFunDef(Some(false), a, N, Nil, L(App(Var("foo"), Tup((N, IntLit(42)), (N, Var("true")))))), NuFunDef(Some(false), b, N, Nil, L(App(Var("foo"), Tup((N, IntLit(23)), (N, Var("false"))))))) +//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,true,false),Var(b))))),If(IfThen(Var(b),Var(x)),Some(IntLit(1337)))))), NuFunDef(Some(false),Var(a),None,List(),Left(App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(42))), (None,Fld(FldFlags(false,false,false),Var(true)))))))), NuFunDef(Some(false),Var(b),None,List(),Left(App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(23))), (None,Fld(FldFlags(false,false,false),Var(false)))))))))) //│ Lifted: //│ TypingUnit { //│ fun foo$3 = (x, #b,) => if (b) then x else 1337 @@ -61,7 +61,7 @@ let b = foo(23, false) :mono let x = 42 + 1337 //│ Parsed: -//│ TypingUnit(NuFunDef(Some(false), x, N, Nil, L(App(Var("+"), Tup((N, IntLit(42)), (N, IntLit(1337))))))) +//│ TypingUnit(List(NuFunDef(Some(false),Var(x),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(42))), (None,Fld(FldFlags(false,false,false),IntLit(1337)))))))))) //│ Lifted: //│ TypingUnit {let x$1 = () => +(42, 1337,)} //│ Mono: @@ -99,7 +99,7 @@ let x = 42 + 1337 if true then 1 else 0 if 1+1 > 1 then 1 - 1 else 1*1 //│ Parsed: -//│ TypingUnit(If(IfThen(Var("true"), IntLit(1), Some(IntLit(0))), If(IfThen(App(Var(">"), Tup((N, App(Var("+"), Tup((N, IntLit(1)), (N, IntLit(1))))), (N, IntLit(1)))), App(Var("-"), Tup((N, IntLit(1)), (N, IntLit(1)))), Some(App(Var("*"), Tup((N, IntLit(1)), (N, IntLit(1))))))) +//│ TypingUnit(List(If(IfThen(Var(true),IntLit(1)),Some(IntLit(0))), If(IfThen(App(Var(>),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))),App(Var(-),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))),Some(App(Var(*),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))))))) //│ Lifted: //│ TypingUnit { //│ Code(List(if (true) then 1 else 0)) @@ -123,7 +123,7 @@ if 1+1 > 1 then 1 - 1 else 1*1 :mono if(b) then 1 else 2 //│ Parsed: -//│ TypingUnit(If(IfThen(Bra(rcd = false, Var("b")), IntLit(1), Some(IntLit(2)))) +//│ TypingUnit(List(If(IfThen(Bra(false,Var(b)),IntLit(1)),Some(IntLit(2))))) //│ Lifted: //│ TypingUnit {Code(List(if ('(' b ')') then 1 else 2))} //│ Mono: @@ -139,7 +139,7 @@ if(b) then 1 else 2 :mono ((f, g) => f(g))(f => f, true) //│ Parsed: -//│ TypingUnit(App(Bra(rcd = false, Lam(Tup((N, Var("f")), (N, Var("g"))), App(Var("f"), Tup((N, Var("g")))))), Tup((N, Lam(Tup((N, Var("f"))), Var("f"))), (N, Var("true"))))) +//│ TypingUnit(List(App(Bra(false,Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(f))), (None,Fld(FldFlags(false,false,false),Var(g))))),App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),Var(g)))))))),Tup(List((None,Fld(FldFlags(false,false,false),Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(f))))),Var(f)))), (None,Fld(FldFlags(false,false,false),Var(true)))))))) //│ Lifted: //│ TypingUnit { //│ class Lambda2$1$1([]) {fun apply = (f, g,) => f(g,)} @@ -168,7 +168,7 @@ if(b) then 1 else 2 :mono (b => if b then true else false) (true) //│ Parsed: -//│ TypingUnit(App(Bra(rcd = false, Lam(Tup((N, Var("b"))), If(IfThen(Var("b"), Var("true"), Some(Var("false"))))), Tup((N, Var("true"))))) +//│ TypingUnit(List(App(Bra(false,Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(b))))),If(IfThen(Var(b),Var(true)),Some(Var(false))))),Tup(List((None,Fld(FldFlags(false,false,false),Var(true)))))))) //│ Lifted: //│ TypingUnit { //│ class Lambda1$1$1([]) {fun apply = (b,) => if (b) then true else false} @@ -193,7 +193,7 @@ fun f(x) = if(x > 0) then x+1 else x - 1 f(2)+3 //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(If(IfThen(Bra(rcd = false, App(Var(">"), Tup((N, Var("x")), (N, IntLit(0))))), App(Var("+"), Tup((N, Var("x")), (N, IntLit(1)))), Some(App(Var("-"), Tup((N, Var("x")), (N, IntLit(1)))))))))), App(Var("+"), Tup((N, App(Var("f"), Tup((N, IntLit(2))))), (N, IntLit(3))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(If(IfThen(Bra(false,App(Var(>),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(0))))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))),Some(App(Var(-),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))))))))), App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))))), (None,Fld(FldFlags(false,false,false),IntLit(3)))))))) //│ Lifted: //│ TypingUnit { //│ fun f$1 = (x,) => {if ('(' >(x, 0,) ')') then +(x, 1,) else -(x, 1,)} @@ -217,7 +217,7 @@ fun fac(n) = if (n > 1) then fac(n - 1) * n else 1 fac(2) //│ Parsed: -//│ TypingUnit(NuFunDef(None, fac, N, Nil, L(Lam(Tup((N, Var("n"))), Blk(If(IfThen(Bra(rcd = false, App(Var(">"), Tup((N, Var("n")), (N, IntLit(1))))), App(Var("*"), Tup((N, App(Var("fac"), Tup((N, App(Var("-"), Tup((N, Var("n")), (N, IntLit(1)))))))), (N, Var("n")))), Some(IntLit(1))))))), App(Var("fac"), Tup((N, IntLit(2))))) +//│ TypingUnit(List(NuFunDef(None,Var(fac),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(n))))),Blk(List(If(IfThen(Bra(false,App(Var(>),Tup(List((None,Fld(FldFlags(false,false,false),Var(n))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))),App(Var(*),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(fac),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(-),Tup(List((None,Fld(FldFlags(false,false,false),Var(n))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))))))))), (None,Fld(FldFlags(false,false,false),Var(n))))))),Some(IntLit(1)))))))), App(Var(fac),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))))) //│ Lifted: //│ TypingUnit { //│ fun fac$1 = (n,) => {if ('(' >(n, 1,) ')') then *(fac$1(-(n, 1,),), n,) else 1} @@ -246,7 +246,7 @@ fun count(lst) = else 0 count(new List(new List(new Nil(undefined, false), true), true)) //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("List"), Ls(), S(Tup((S(Var("l")), App(Var("|"), Tup((N, App(Var("|"), Tup((N, Var("List")), (N, Var("Nil"))))), (N, UnitLit(true))))), (S(Var("hasTail")), Var("Bool")))), N, N, Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("Nil"), Ls(), S(Tup((S(Var("l")), App(Var("|"), Tup((N, App(Var("|"), Tup((N, Var("List")), (N, Var("Nil"))))), (N, UnitLit(true))))), (S(Var("hasTail")), Var("Bool")))), N, N, Ls(), N, N, TypingUnit()), NuFunDef(None, count, N, Nil, L(Lam(Tup((N, Var("lst"))), Blk(If(IfThen(Sel(Var("lst"), hasTail), Blk(NuFunDef(Some(false), l, N, Nil, L(Sel(Var("lst"), l))), If(IfThen(App(Var("is"), Tup((N, Var("l")), (N, UnitLit(true)))), IntLit(1), Some(App(Var("+"), Tup((N, App(Var("count"), Tup((N, Var("l"))))), (N, IntLit(1))))))), Some(IntLit(0))))))), App(Var("count"), Tup((N, App(NuNew(Var("List")), Tup((N, App(NuNew(Var("List")), Tup((N, App(NuNew(Var("Nil")), Tup((N, UnitLit(true)), (N, Var("false"))))), (N, Var("true"))))), (N, Var("true")))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(List),List(),Some(Tup(List((Some(Var(l)),Fld(FldFlags(false,false,true),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),Var(List))), (None,Fld(FldFlags(false,false,false),Var(Nil)))))))), (None,Fld(FldFlags(false,false,false),UnitLit(true)))))))), (Some(Var(hasTail)),Fld(FldFlags(false,false,true),Var(Bool)))))),None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List((Some(Var(l)),Fld(FldFlags(false,false,true),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),Var(List))), (None,Fld(FldFlags(false,false,false),Var(Nil)))))))), (None,Fld(FldFlags(false,false,false),UnitLit(true)))))))), (Some(Var(hasTail)),Fld(FldFlags(false,false,true),Var(Bool)))))),None,None,List(),None,None,TypingUnit(List())), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(lst))))),Blk(List(If(IfThen(Sel(Var(lst),Var(hasTail)),Blk(List(NuFunDef(Some(false),Var(l),None,List(),Left(Sel(Var(lst),Var(l)))), If(IfThen(App(Var(is),Tup(List((None,Fld(FldFlags(false,false,false),Var(l))), (None,Fld(FldFlags(false,false,false),UnitLit(true)))))),IntLit(1)),Some(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(count),Tup(List((None,Fld(FldFlags(false,false,false),Var(l)))))))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))))))),Some(IntLit(0)))))))), App(Var(count),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Nil)),Tup(List((None,Fld(FldFlags(false,false,false),UnitLit(true))), (None,Fld(FldFlags(false,false,false),Var(false)))))))), (None,Fld(FldFlags(false,false,false),Var(true)))))))), (None,Fld(FldFlags(false,false,false),Var(true))))))))))))) //│ Lifted: //│ TypingUnit { //│ class List$1([val l: |(|(List, Nil,), undefined,), val hasTail: Bool,]) {} @@ -303,7 +303,7 @@ class Nil() { fun add2(x) = x+2 (new List(1, new List(2, new Nil()))).map(x => x+1).map(x => add2(x)) //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("List"), Ls(), S(Tup((S(Var("e")), Var("Int")), (S(Var("tail")), App(Var("|"), Tup((N, Var("List")), (N, Var("Nil"))))))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, map, N, Nil, R(PolyType(Ls(), Function(Tuple(N -> Fld(N, Function(Tuple(N -> Fld(N, TypeName("Int"))), TypeName("Int")))), TypeName("List"))))), NuFunDef(None, map, N, Nil, L(Lam(Tup((N, Var("f"))), App(NuNew(Var("List")), Tup((N, App(Var("f"), Tup((N, Var("e"))))), (N, App(Sel(Var("tail"), map), Tup((N, Var("f")))))))))), NuFunDef(None, count, N, Nil, R(PolyType(Ls(), Function(Tuple(), TypeName("Int"))))), NuFunDef(None, count, N, Nil, L(Lam(Tup(), App(Var("+"), Tup((N, IntLit(1)), (N, App(Sel(Var("tail"), count), Tup()))))))))), NuTypeDef(Cls, TypeName("Nil"), Ls(), S(Tup()), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, map, N, Nil, L(Lam(Tup((N, Var("f"))), Var("this")))), NuFunDef(None, count, N, Nil, L(Lam(Tup(), IntLit(0)))))), NuFunDef(None, add2, N, Nil, L(Lam(Tup((N, Var("x"))), App(Var("+"), Tup((N, Var("x")), (N, IntLit(2))))))), App(Sel(App(Sel(Bra(rcd = false, App(NuNew(Var("List")), Tup((N, IntLit(1)), (N, App(NuNew(Var("List")), Tup((N, IntLit(2)), (N, App(NuNew(Var("Nil")), Tup())))))))), map), Tup((N, Lam(Tup((N, Var("x"))), App(Var("+"), Tup((N, Var("x")), (N, IntLit(1)))))))), map), Tup((N, Lam(Tup((N, Var("x"))), App(Var("add2"), Tup((N, Var("x"))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(List),List(),Some(Tup(List((Some(Var(e)),Fld(FldFlags(false,false,false),Var(Int))), (Some(Var(tail)),Fld(FldFlags(false,false,false),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),Var(List))), (None,Fld(FldFlags(false,false,false),Var(Nil))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(map),None,List(),Right(PolyType(List(),Function(Tuple(List((None,Field(None,Function(Tuple(List((None,Field(None,TypeName(Int))))),TypeName(Int)))))),TypeName(List))))), NuFunDef(None,Var(map),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(f))))),App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),Var(e)))))))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(tail),Var(map)),Tup(List((None,Fld(FldFlags(false,false,false),Var(f)))))))))))))), NuFunDef(None,Var(count),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(tail),Var(count)),Tup(List()))))))))))))), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(map),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(f))))),Var(this)))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),IntLit(0))))))), NuFunDef(None,Var(add2),None,List(),Left(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(2))))))))), App(Sel(App(Sel(Bra(false,App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2))), (None,Fld(FldFlags(false,false,false),App(NuNew(Var(Nil)),Tup(List()))))))))))))),Var(map)),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)))))))))))),Var(map)),Tup(List((None,Fld(FldFlags(false,false,false),Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),App(Var(add2),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))))))))) //│ Lifted: //│ TypingUnit { //│ class List$1([e: Int, tail: |(List, Nil,),]) { @@ -370,7 +370,7 @@ fun generate(x) = foo(new List(1, new List(2, new Nil()))) foo(generate(1)) //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("List"), Ls(), S(Tup((S(Var("e")), Var("Int")), (S(Var("tail")), App(Var("|"), Tup((N, Var("List")), (N, Var("Nil"))))))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, count, N, Nil, R(PolyType(Ls(), Function(Tuple(), TypeName("Int"))))), NuFunDef(None, count, N, Nil, L(Lam(Tup(), App(Var("+"), Tup((N, IntLit(1)), (N, App(Sel(Var("tail"), count), Tup()))))))))), NuTypeDef(Cls, TypeName("Nil"), Ls(), S(Tup()), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, count, N, Nil, L(Lam(Tup(), IntLit(0)))))), NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("x"))), App(Sel(Var("x"), count), Tup())))), NuFunDef(None, generate, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(If(IfThen(App(Var(">"), Tup((N, Var("x")), (N, IntLit(0)))), App(NuNew(Var("List")), Tup((N, Var("x")), (N, App(Var("generate"), Tup((N, App(Var("+"), Tup((N, Var("x")), (N, IntLit(1)))))))))), Some(App(NuNew(Var("Nil")), Tup()))))))), App(Var("foo"), Tup((N, App(NuNew(Var("List")), Tup((N, IntLit(1)), (N, App(NuNew(Var("List")), Tup((N, IntLit(2)), (N, App(NuNew(Var("Nil")), Tup())))))))))), App(Var("foo"), Tup((N, App(Var("generate"), Tup((N, IntLit(1)))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(List),List(),Some(Tup(List((Some(Var(e)),Fld(FldFlags(false,false,false),Var(Int))), (Some(Var(tail)),Fld(FldFlags(false,false,false),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),Var(List))), (None,Fld(FldFlags(false,false,false),Var(Nil))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(tail),Var(count)),Tup(List()))))))))))))), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),IntLit(0))))))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),App(Sel(Var(x),Var(count)),Tup(List()))))), NuFunDef(None,Var(generate),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(If(IfThen(App(Var(>),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(0)))))),App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),App(Var(generate),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))))))))))))),Some(App(NuNew(Var(Nil)),Tup(List()))))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2))), (None,Fld(FldFlags(false,false,false),App(NuNew(Var(Nil)),Tup(List()))))))))))))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(generate),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))))))))))))) //│ Lifted: //│ TypingUnit { //│ class List$1([e: Int, tail: |(List, Nil,),]) { @@ -424,7 +424,7 @@ fun foo(x) = (f => f(x))(z => z+1) foo(2) //│ Parsed: -//│ TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(App(Bra(rcd = false, Lam(Tup((N, Var("f"))), App(Var("f"), Tup((N, Var("x")))))), Tup((N, Lam(Tup((N, Var("z"))), App(Var("+"), Tup((N, Var("z")), (N, IntLit(1)))))))))))), App(Var("foo"), Tup((N, IntLit(2))))) +//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(App(Bra(false,Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(f))))),App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))),Tup(List((None,Fld(FldFlags(false,false,false),Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(z))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(z))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))))))))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))))) //│ Lifted: //│ TypingUnit { //│ class Lambda1$2$1([x,]) {fun apply = (f,) => f((this).x,)} @@ -458,7 +458,7 @@ fun f(x) = (y => f(x+y))(x+1) f(1) //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(App(Bra(rcd = false, Lam(Tup((N, Var("y"))), App(Var("f"), Tup((N, App(Var("+"), Tup((N, Var("x")), (N, Var("y"))))))))), Tup((N, App(Var("+"), Tup((N, Var("x")), (N, IntLit(1))))))))))), App(Var("f"), Tup((N, IntLit(1))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(App(Bra(false,Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(y))))),App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y))))))))))))),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))))))))))))), App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))))) //│ Lifted: //│ TypingUnit { //│ class Lambda1$2$1([x,]) {fun apply = (y,) => f$1(+((this).x, y,),)} @@ -489,7 +489,7 @@ fun f(x) = f(x) f(0) f(1) //│ Parsed: -//│ TypingUnit(NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x"))), App(Var("f"), Tup((N, Var("x"))))))), App(Var("f"), Tup((N, IntLit(0)))), App(Var("f"), Tup((N, IntLit(1))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))))))), App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))), App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))))) //│ Lifted: //│ TypingUnit { //│ fun f$1 = (x,) => f$1(x,) @@ -537,7 +537,7 @@ fun foo(x) = foo(new Lambda()) foo(new Lambda2(2)) //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("Cons"), Ls(), S(Tup((S(Var("e")), Var("'A")), (S(Var("tail")), App(Var("|"), Tup((N, Var("Cons")), (N, Var("Nil"))))))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, count, N, Nil, R(PolyType(Ls(), Function(Tuple(), TypeName("Int"))))), NuFunDef(None, count, N, Nil, L(Lam(Tup(), App(Var("+"), Tup((N, IntLit(1)), (N, App(Sel(Var("tail"), count), Tup()))))))))), NuTypeDef(Cls, TypeName("Nil"), Ls(), S(Tup()), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, count, N, Nil, L(Lam(Tup(), IntLit(0)))))), NuTypeDef(Cls, TypeName("Lambda"), Ls(), S(Tup()), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, apply, N, Nil, L(Lam(Tup((N, Var("l"))), Blk(App(Sel(Var("l"), count), Tup()))))))), NuTypeDef(Cls, TypeName("Lambda2"), Ls(), S(Tup((S(Var("a")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, apply, N, Nil, L(Lam(Tup((N, Var("l"))), Blk(App(Sel(Bra(rcd = false, App(NuNew(Var("Cons")), Tup((N, Var("a")), (N, Var("l"))))), count), Tup()))))))), NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(App(Var("+"), Tup((N, App(Sel(Var("x"), apply), Tup((N, App(NuNew(Var("Cons")), Tup((N, IntLit(1)), (N, App(NuNew(Var("Nil")), Tup())))))))), (N, App(Sel(Var("x"), apply), Tup((N, App(NuNew(Var("Nil")), Tup()))))))))))), App(Var("foo"), Tup((N, App(NuNew(Var("Lambda")), Tup())))), App(Var("foo"), Tup((N, App(NuNew(Var("Lambda2")), Tup((N, IntLit(2)))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Cons),List(),Some(Tup(List((Some(Var(e)),Fld(FldFlags(false,false,false),Var('A))), (Some(Var(tail)),Fld(FldFlags(false,false,false),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),Var(Cons))), (None,Fld(FldFlags(false,false,false),Var(Nil))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(tail),Var(count)),Tup(List()))))))))))))), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),IntLit(0))))))), NuTypeDef(Cls,TypeName(Lambda),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(apply),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(l))))),Blk(List(App(Sel(Var(l),Var(count)),Tup(List())))))))))), NuTypeDef(Cls,TypeName(Lambda2),List(),Some(Tup(List((Some(Var(a)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(apply),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(l))))),Blk(List(App(Sel(Bra(false,App(NuNew(Var(Cons)),Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),Var(l))))))),Var(count)),Tup(List())))))))))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Sel(Var(x),Var(apply)),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Cons)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(NuNew(Var(Nil)),Tup(List())))))))))))))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(x),Var(apply)),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Nil)),Tup(List()))))))))))))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Lambda)),Tup(List()))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Lambda2)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2))))))))))))) //│ Lifted: //│ TypingUnit { //│ class Cons$1([e: 'A, tail: |(Cons, Nil,),]) { @@ -612,7 +612,7 @@ fun foo(x) = foo(l => l.count()) foo(l => (new Cons(2, l)).count()) //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("Cons"), Ls(), S(Tup((S(Var("e")), Var("Int")), (S(Var("tail")), App(Var("|"), Tup((N, Var("Cons")), (N, Var("Nil"))))))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, count, N, Nil, R(PolyType(Ls(), Function(Tuple(), TypeName("Int"))))), NuFunDef(None, count, N, Nil, L(Lam(Tup(), App(Var("+"), Tup((N, IntLit(1)), (N, App(Sel(Var("tail"), count), Tup()))))))))), NuTypeDef(Cls, TypeName("Nil"), Ls(), S(Tup()), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, count, N, Nil, L(Lam(Tup(), IntLit(0)))))), NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(App(Var("+"), Tup((N, App(Var("x"), Tup((N, App(NuNew(Var("Cons")), Tup((N, IntLit(1)), (N, App(NuNew(Var("Nil")), Tup())))))))), (N, App(Var("x"), Tup((N, App(NuNew(Var("Nil")), Tup()))))))))))), App(Var("foo"), Tup((N, Lam(Tup((N, Var("l"))), App(Sel(Var("l"), count), Tup()))))), App(Var("foo"), Tup((N, Lam(Tup((N, Var("l"))), App(Sel(Bra(rcd = false, App(NuNew(Var("Cons")), Tup((N, IntLit(2)), (N, Var("l"))))), count), Tup())))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Cons),List(),Some(Tup(List((Some(Var(e)),Fld(FldFlags(false,false,false),Var(Int))), (Some(Var(tail)),Fld(FldFlags(false,false,false),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),Var(Cons))), (None,Fld(FldFlags(false,false,false),Var(Nil))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(tail),Var(count)),Tup(List()))))))))))))), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),IntLit(0))))))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(x),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Cons)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(NuNew(Var(Nil)),Tup(List())))))))))))))), (None,Fld(FldFlags(false,false,false),App(Var(x),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Nil)),Tup(List()))))))))))))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(l))))),App(Sel(Var(l),Var(count)),Tup(List())))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(l))))),App(Sel(Bra(false,App(NuNew(Var(Cons)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2))), (None,Fld(FldFlags(false,false,false),Var(l))))))),Var(count)),Tup(List())))))))))) //│ Lifted: //│ TypingUnit { //│ class Cons$1([e: Int, tail: |(Cons, Nil,),]) { @@ -707,7 +707,7 @@ class C(e1: Exp, e2: Exp) extends Exp { } (new C(new Ch(1), new A(new Ch(2), new Ch(3)))).derive(0).isEmpty() //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("Exp"), Ls(), S(Tup()), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, derive, N, Nil, R(PolyType(Ls(), Function(Tuple(S(x) -> Fld(N, TypeName("Int"))), TypeName("Exp"))))), NuFunDef(None, derive, N, Nil, L(Lam(Tup((S(Var("x")), Var("Int"))), App(Var("Exp"), Tup())))), NuFunDef(None, isEmpty, N, Nil, R(PolyType(Ls(), Function(Tuple(), TypeName("Bool"))))), NuFunDef(None, isEmpty, N, Nil, L(Lam(Tup(), Var("false")))))), NuTypeDef(Cls, TypeName("E"), Ls(), S(Tup()), N, N, Ls(Var("Exp")), N, N, TypingUnit(NuFunDef(None, derive, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(NuNew(Var("E")))))), NuFunDef(None, isEmpty, N, Nil, L(Lam(Tup(), Blk(Var("false"))))))), NuTypeDef(Cls, TypeName("Ep"), Ls(), S(Tup()), N, N, Ls(Var("Exp")), N, N, TypingUnit(NuFunDef(None, derive, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(NuNew(Var("E")))))), NuFunDef(None, isEmpty, N, Nil, L(Lam(Tup(), Blk(Var("true"))))))), NuTypeDef(Cls, TypeName("Ch"), Ls(), S(Tup((S(Var("i")), Var("Int")))), N, N, Ls(Var("Exp")), N, N, TypingUnit(NuFunDef(None, derive, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(If(IfThen(App(Var("=="), Tup((N, Var("x")), (N, Var("i")))), NuNew(Var("Ep")), Some(NuNew(Var("E")))))))), NuFunDef(None, isEmpty, N, Nil, L(Lam(Tup(), Blk(Var("false"))))))), NuTypeDef(Cls, TypeName("A"), Ls(), S(Tup((S(Var("e1")), Var("Exp")), (S(Var("e2")), Var("Exp")))), N, N, Ls(Var("Exp")), N, N, TypingUnit(NuFunDef(None, derive, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(App(NuNew(Var("A")), Tup((N, App(Sel(Var("e1"), derive), Tup((N, Var("x"))))), (N, App(Sel(Var("e2"), derive), Tup((N, Var("x"))))))))))), NuFunDef(None, isEmpty, N, Nil, L(Lam(Tup(), Blk(App(Var("||"), Tup((N, App(Sel(Var("e1"), isEmpty), Tup())), (N, App(Sel(Var("e2"), isEmpty), Tup())))))))))), NuTypeDef(Cls, TypeName("C"), Ls(), S(Tup((S(Var("e1")), Var("Exp")), (S(Var("e2")), Var("Exp")))), N, N, Ls(Var("Exp")), N, N, TypingUnit(NuFunDef(None, derive, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(If(IfThen(App(Sel(Var("e1"), isEmpty), Tup()), App(NuNew(Var("A")), Tup((N, App(NuNew(Var("C")), Tup((N, App(Sel(Var("e1"), derive), Tup((N, Var("x"))))), (N, Var("e2"))))), (N, App(Sel(Var("e2"), derive), Tup((N, Var("x"))))))), Some(App(NuNew(Var("C")), Tup((N, App(Sel(Var("e1"), derive), Tup((N, Var("x"))))), (N, Var("e2")))))))))), NuFunDef(None, isEmpty, N, Nil, L(Lam(Tup(), Blk(App(Var("&&"), Tup((N, App(Sel(Var("e1"), isEmpty), Tup())), (N, App(Sel(Var("e2"), isEmpty), Tup())))))))))), App(Sel(App(Sel(Bra(rcd = false, App(NuNew(Var("C")), Tup((N, App(NuNew(Var("Ch")), Tup((N, IntLit(1))))), (N, App(NuNew(Var("A")), Tup((N, App(NuNew(Var("Ch")), Tup((N, IntLit(2))))), (N, App(NuNew(Var("Ch")), Tup((N, IntLit(3))))))))))), derive), Tup((N, IntLit(0)))), isEmpty), Tup())) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Exp),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Right(PolyType(List(),Function(Tuple(List((Some(Var(x)),Field(None,TypeName(Int))))),TypeName(Exp))))), NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(Int))))),App(Var(Exp),Tup(List()))))), NuFunDef(None,Var(isEmpty),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Bool))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Var(false))))))), NuTypeDef(Cls,TypeName(E),List(),Some(Tup(List())),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(NuNew(Var(E))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(Var(false))))))))), NuTypeDef(Cls,TypeName(Ep),List(),Some(Tup(List())),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(NuNew(Var(E))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(Var(true))))))))), NuTypeDef(Cls,TypeName(Ch),List(),Some(Tup(List((Some(Var(i)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(If(IfThen(App(Var(==),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(i)))))),NuNew(Var(Ep))),Some(NuNew(Var(E))))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(Var(false))))))))), NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((Some(Var(e1)),Fld(FldFlags(false,false,false),Var(Exp))), (Some(Var(e2)),Fld(FldFlags(false,false,false),Var(Exp)))))),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(App(NuNew(Var(A)),Tup(List((None,Fld(FldFlags(false,false,false),App(Sel(Var(e1),Var(derive)),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(e2),Var(derive)),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))))))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(App(Var(||),Tup(List((None,Fld(FldFlags(false,false,false),App(Sel(Var(e1),Var(isEmpty)),Tup(List())))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(e2),Var(isEmpty)),Tup(List()))))))))))))))), NuTypeDef(Cls,TypeName(C),List(),Some(Tup(List((Some(Var(e1)),Fld(FldFlags(false,false,false),Var(Exp))), (Some(Var(e2)),Fld(FldFlags(false,false,false),Var(Exp)))))),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(If(IfThen(App(Sel(Var(e1),Var(isEmpty)),Tup(List())),App(NuNew(Var(A)),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(C)),Tup(List((None,Fld(FldFlags(false,false,false),App(Sel(Var(e1),Var(derive)),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))), (None,Fld(FldFlags(false,false,false),Var(e2)))))))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(e2),Var(derive)),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))))))),Some(App(NuNew(Var(C)),Tup(List((None,Fld(FldFlags(false,false,false),App(Sel(Var(e1),Var(derive)),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))), (None,Fld(FldFlags(false,false,false),Var(e2))))))))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(App(Var(&&),Tup(List((None,Fld(FldFlags(false,false,false),App(Sel(Var(e1),Var(isEmpty)),Tup(List())))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(e2),Var(isEmpty)),Tup(List()))))))))))))))), App(Sel(App(Sel(Bra(false,App(NuNew(Var(C)),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Ch)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))))), (None,Fld(FldFlags(false,false,false),App(NuNew(Var(A)),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Ch)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))))), (None,Fld(FldFlags(false,false,false),App(NuNew(Var(Ch)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(3))))))))))))))))),Var(derive)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))),Var(isEmpty)),Tup(List())))) //│ Lifted: //│ TypingUnit { //│ class Exp$1([]) { @@ -809,7 +809,7 @@ fun gen() = if anyUnknown then new List(gen(), true) else new Nil(false) gen() //│ Parsed: -//│ TypingUnit(NuFunDef(Some(false), anyUnknown, N, Nil, L(Var("false"))), NuTypeDef(Cls, TypeName("List"), Ls(), S(Tup((S(Var("l")), App(Var("|"), Tup((N, Var("List")), (N, Var("Nil"))))), (S(Var("hasTail")), Var("Bool")))), N, N, Ls(), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("Nil"), Ls(), S(Tup((S(Var("hasTail")), Var("Bool")))), N, N, Ls(), N, N, TypingUnit()), NuFunDef(None, gen, N, Nil, L(Lam(Tup(), Blk(If(IfThen(Var("anyUnknown"), App(NuNew(Var("List")), Tup((N, App(Var("gen"), Tup())), (N, Var("true")))), Some(App(NuNew(Var("Nil")), Tup((N, Var("false")))))))))), App(Var("gen"), Tup())) +//│ TypingUnit(List(NuFunDef(Some(false),Var(anyUnknown),None,List(),Left(Var(false))), NuTypeDef(Cls,TypeName(List),List(),Some(Tup(List((Some(Var(l)),Fld(FldFlags(false,false,false),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),Var(List))), (None,Fld(FldFlags(false,false,false),Var(Nil)))))))), (Some(Var(hasTail)),Fld(FldFlags(false,false,false),Var(Bool)))))),None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List((Some(Var(hasTail)),Fld(FldFlags(false,false,false),Var(Bool)))))),None,None,List(),None,None,TypingUnit(List())), NuFunDef(None,Var(gen),None,List(),Left(Lam(Tup(List()),Blk(List(If(IfThen(Var(anyUnknown),App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(gen),Tup(List())))), (None,Fld(FldFlags(false,false,false),Var(true))))))),Some(App(NuNew(Var(Nil)),Tup(List((None,Fld(FldFlags(false,false,false),Var(false))))))))))))), App(Var(gen),Tup(List())))) //│ Lifted: //│ TypingUnit { //│ class List$1([l: |(List, Nil,), hasTail: Bool,]) {} @@ -851,7 +851,7 @@ class Foo(x: Int){ } (new Foo(1)).boo(2) //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("Foo"), Ls(), S(Tup((S(Var("x")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, bar, N, Nil, L(Lam(Tup((N, Var("y"))), App(Var("+"), Tup((N, Var("x")), (N, Var("y"))))))), NuFunDef(None, boo, N, Nil, L(Lam(Tup((N, Var("z"))), App(Var("+"), Tup((N, App(Var("bar"), Tup((N, Var("z"))))), (N, Var("x"))))))))), App(Sel(Bra(rcd = false, App(NuNew(Var("Foo")), Tup((N, IntLit(1))))), boo), Tup((N, IntLit(2))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((Some(Var(x)),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(y))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y))))))))), NuFunDef(None,Var(boo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(z))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(bar),Tup(List((None,Fld(FldFlags(false,false,false),Var(z)))))))), (None,Fld(FldFlags(false,false,false),Var(x)))))))))))), App(Sel(Bra(false,App(NuNew(Var(Foo)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))))))),Var(boo)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))))) //│ Lifted: //│ TypingUnit { //│ class Foo$1([x: Int,]) { @@ -888,7 +888,7 @@ class OneInt(a: Int){ } (new OneInt(10)).fac() //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("OneInt"), Ls(), S(Tup((S(Var("a")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, fac, N, Nil, R(PolyType(Ls(), Function(Tuple(), TypeName("Int"))))), NuFunDef(None, fac, N, Nil, L(Lam(Tup(), Blk(If(IfThen(Bra(rcd = false, App(Var(">"), Tup((N, Var("a")), (N, IntLit(0))))), App(Sel(Bra(rcd = false, App(NuNew(Var("OneInt")), Tup((N, App(Var("-"), Tup((N, Var("a")), (N, IntLit(1)))))))), fac), Tup()), Some(IntLit(1))))))))), App(Sel(Bra(rcd = false, App(NuNew(Var("OneInt")), Tup((N, IntLit(10))))), fac), Tup())) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(OneInt),List(),Some(Tup(List((Some(Var(a)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(fac),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(fac),None,List(),Left(Lam(Tup(List()),Blk(List(If(IfThen(Bra(false,App(Var(>),Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),IntLit(0))))))),App(Sel(Bra(false,App(NuNew(Var(OneInt)),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(-),Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))))))))),Var(fac)),Tup(List()))),Some(IntLit(1))))))))))), App(Sel(Bra(false,App(NuNew(Var(OneInt)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(10))))))),Var(fac)),Tup(List())))) //│ Lifted: //│ TypingUnit { //│ class OneInt$1([a: Int,]) { @@ -938,7 +938,7 @@ fun g(x) = else f(x - 2) g(1) //│ Parsed: -//│ TypingUnit(NuFunDef(Some(false), any, N, Nil, L(IntLit(-20))), NuFunDef(None, f, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(If(IfThen(App(Var(">"), Tup((N, Var("x")), (N, Var("any")))), IntLit(0), Some(App(Var("g"), Tup((N, App(Var("-"), Tup((N, Var("x")), (N, IntLit(1))))))))))))), NuFunDef(None, g, N, Nil, L(Lam(Tup((N, Var("x"))), Blk(If(IfThen(App(Var(">"), Tup((N, Var("x")), (N, Var("any")))), App(Var("g"), Tup((N, App(Var("-"), Tup((N, Var("x")), (N, IntLit(1))))))), Some(App(Var("f"), Tup((N, App(Var("-"), Tup((N, Var("x")), (N, IntLit(2))))))))))))), App(Var("g"), Tup((N, IntLit(1))))) +//│ TypingUnit(List(NuFunDef(Some(false),Var(any),None,List(),Left(IntLit(-20))), NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(If(IfThen(App(Var(>),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(any)))))),IntLit(0)),Some(App(Var(g),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(-),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))))))))))))))), NuFunDef(None,Var(g),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(If(IfThen(App(Var(>),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(any)))))),App(Var(g),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(-),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))))))))),Some(App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(-),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(2)))))))))))))))))), App(Var(g),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))))) //│ Lifted: //│ TypingUnit { //│ let any$3 = () => -20 @@ -977,7 +977,7 @@ class OneBool(b: Bool){ } (if b then new OneInt(1) else new OneBool(true)).get() //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("OneInt"), Ls(), S(Tup((S(Var("a")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, get, N, Nil, L(Lam(Tup(), Var("a")))))), NuTypeDef(Cls, TypeName("OneBool"), Ls(), S(Tup((S(Var("b")), Var("Bool")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, get, N, Nil, L(Lam(Tup(), Var("b")))))), App(Sel(Bra(rcd = false, If(IfThen(Var("b"), App(NuNew(Var("OneInt")), Tup((N, IntLit(1)))), Some(App(NuNew(Var("OneBool")), Tup((N, Var("true"))))))), get), Tup())) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(OneInt),List(),Some(Tup(List((Some(Var(a)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(get),None,List(),Left(Lam(Tup(List()),Var(a))))))), NuTypeDef(Cls,TypeName(OneBool),List(),Some(Tup(List((Some(Var(b)),Fld(FldFlags(false,false,false),Var(Bool)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(get),None,List(),Left(Lam(Tup(List()),Var(b))))))), App(Sel(Bra(false,If(IfThen(Var(b),App(NuNew(Var(OneInt)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))))))),Some(App(NuNew(Var(OneBool)),Tup(List((None,Fld(FldFlags(false,false,false),Var(true))))))))),Var(get)),Tup(List())))) //│ Lifted: //│ TypingUnit { //│ class OneInt$1([a: Int,]) {fun get = () => (this).a} @@ -1023,7 +1023,7 @@ baz(bar) (new Car()).da(Bar(1337)) bar.car //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("Bar"), Ls(), S(Tup((S(Var("x")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup((N, Var("x"))), Var("x")))), NuFunDef(None, FooMinus, N, Nil, L(Lam(Tup((S(Var("y")), Var("Int"))), App(Var("+"), Tup((N, Var("x")), (N, Var("y"))))))), NuFunDef(None, car, N, Nil, L(App(Var("foo"), Tup((N, IntLit(2)))))))), NuTypeDef(Cls, TypeName("Car"), Ls(), N, N, N, Ls(), N, N, TypingUnit(NuFunDef(None, da, N, Nil, L(Lam(Tup((S(Var("b")), Var("Bar"))), App(Sel(Var("b"), foo), Tup((N, IntLit(2))))))))), NuFunDef(None, baz, N, Nil, L(Lam(Tup((S(Var("b")), Var("Bar"))), App(Sel(Var("b"), foo), Tup((N, IntLit(2))))))), NuFunDef(Some(false), bar, N, Nil, L(App(Var("Bar"), Tup((N, IntLit(42)))))), App(Var("baz"), Tup((N, Var("bar")))), App(Sel(Bra(rcd = false, App(NuNew(Var("Car")), Tup())), da), Tup((N, App(Var("Bar"), Tup((N, IntLit(1337))))))), Sel(Var("bar"), car)) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Bar),List(),Some(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Var(x)))), NuFunDef(None,Var(FooMinus),None,List(),Left(Lam(Tup(List((Some(Var(y)),Fld(FldFlags(false,false,false),Var(Int))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y))))))))), NuFunDef(None,Var(car),None,List(),Left(App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2))))))))))), NuTypeDef(Cls,TypeName(Car),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(da),None,List(),Left(Lam(Tup(List((Some(Var(b)),Fld(FldFlags(false,false,false),Var(Bar))))),App(Sel(Var(b),Var(foo)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))))))))), NuFunDef(None,Var(baz),None,List(),Left(Lam(Tup(List((Some(Var(b)),Fld(FldFlags(false,false,false),Var(Bar))))),App(Sel(Var(b),Var(foo)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2))))))))), NuFunDef(Some(false),Var(bar),None,List(),Left(App(Var(Bar),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(42)))))))), App(Var(baz),Tup(List((None,Fld(FldFlags(false,false,false),Var(bar)))))), App(Sel(Bra(false,App(NuNew(Var(Car)),Tup(List()))),Var(da)),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(Bar),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1337))))))))))), Sel(Var(bar),Var(car)))) //│ Lifted: //│ TypingUnit { //│ class Bar$1([x: Int,]) { @@ -1094,7 +1094,7 @@ class Sub2(c: Int) extends Sub(c+c){ (new Sub(10)).foo() (new Sub2(c)).foo() //│ Parsed: -//│ TypingUnit(NuFunDef(Some(false), c, N, Nil, L(IntLit(5))), NuTypeDef(Cls, TypeName("Sup"), Ls(), S(Tup((S(Var("a")), Var("Int")))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup(), Var("a")))))), NuTypeDef(Cls, TypeName("Sub"), Ls(), S(Tup((S(Var("b")), Var("Int")))), N, N, Ls(App(Var("Sup"), Tup((N, App(Var("+"), Tup((N, Var("b")), (N, Var("b")))))))), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("Sub2"), Ls(), S(Tup((S(Var("c")), Var("Int")))), N, N, Ls(App(Var("Sub"), Tup((N, App(Var("+"), Tup((N, Var("c")), (N, Var("c")))))))), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup(), App(Var("+"), Tup((N, Var("a")), (N, Var("c"))))))))), App(Sel(Bra(rcd = false, App(NuNew(Var("Sub")), Tup((N, IntLit(10))))), foo), Tup()), App(Sel(Bra(rcd = false, App(NuNew(Var("Sub2")), Tup((N, Var("c"))))), foo), Tup())) +//│ TypingUnit(List(NuFunDef(Some(false),Var(c),None,List(),Left(IntLit(5))), NuTypeDef(Cls,TypeName(Sup),List(),Some(Tup(List((Some(Var(a)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List()),Var(a))))))), NuTypeDef(Cls,TypeName(Sub),List(),Some(Tup(List((Some(Var(b)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(App(Var(Sup),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(b))), (None,Fld(FldFlags(false,false,false),Var(b)))))))))))),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(Sub2),List(),Some(Tup(List((Some(Var(c)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(App(Var(Sub),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(c))), (None,Fld(FldFlags(false,false,false),Var(c)))))))))))),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),Var(c)))))))))))), App(Sel(Bra(false,App(NuNew(Var(Sub)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(10))))))),Var(foo)),Tup(List())), App(Sel(Bra(false,App(NuNew(Var(Sub2)),Tup(List((None,Fld(FldFlags(false,false,false),Var(c))))))),Var(foo)),Tup(List())))) //│ Lifted: //│ TypingUnit { //│ class Sup$1([a: Int,]) {fun foo = () => (this).a} @@ -1152,7 +1152,7 @@ class F2() extends Foo(x => x+2){} (new F1()).foo() (new F2()).foo() //│ Parsed: -//│ TypingUnit(NuTypeDef(Cls, TypeName("Foo"), Ls(), S(Tup((S(Var("f")), App(Var("->"), Tup((N, Var("Int")), (N, Var("Int"))))))), N, N, Ls(), N, N, TypingUnit(NuFunDef(None, foo, N, Nil, L(Lam(Tup(), App(Var("f"), Tup((N, IntLit(1))))))))), NuTypeDef(Cls, TypeName("F1"), Ls(), S(Tup()), N, N, Ls(App(Var("Foo"), Tup((N, Lam(Tup((N, Var("x"))), App(Var("+"), Tup((N, Var("x")), (N, IntLit(1))))))))), N, N, TypingUnit()), NuTypeDef(Cls, TypeName("F2"), Ls(), S(Tup()), N, N, Ls(App(Var("Foo"), Tup((N, Lam(Tup((N, Var("x"))), App(Var("+"), Tup((N, Var("x")), (N, IntLit(2))))))))), N, N, TypingUnit()), App(Sel(Bra(rcd = false, App(NuNew(Var("F1")), Tup())), foo), Tup()), App(Sel(Bra(rcd = false, App(NuNew(Var("F2")), Tup())), foo), Tup())) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((Some(Var(f)),Fld(FldFlags(false,false,false),App(Var(->),Tup(List((None,Fld(FldFlags(false,false,false),Var(Int))), (None,Fld(FldFlags(false,false,false),Var(Int))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List()),App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))))))))), NuTypeDef(Cls,TypeName(F1),List(),Some(Tup(List())),None,None,List(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))))))))))))),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(F2),List(),Some(Tup(List())),None,None,List(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(2))))))))))))),None,None,TypingUnit(List())), App(Sel(Bra(false,App(NuNew(Var(F1)),Tup(List()))),Var(foo)),Tup(List())), App(Sel(Bra(false,App(NuNew(Var(F2)),Tup(List()))),Var(foo)),Tup(List())))) //│ Lifted: //│ TypingUnit { //│ class Foo$1([f: ->(Int, Int,),]) {fun foo = () => (this).f(1,)} From 23c364525fc73a55770aa8bebb9ae4ba7c3519e8 Mon Sep 17 00:00:00 2001 From: Luyu Cheng Date: Sun, 31 Dec 2023 03:40:42 +0800 Subject: [PATCH 06/11] Use a shorthand notation for `FldFlags` --- compiler/shared/test/diff/LambLift.mls | 8 +-- compiler/shared/test/diff/LiftType.mls | 10 ++-- compiler/shared/test/diff/Lifter.mls | 22 ++++---- compiler/shared/test/diff/LifterBlks.mls | 32 ++++++------ compiler/shared/test/diff/mono.mls | 50 +++++++++---------- shared/src/main/scala/mlscript/helpers.scala | 9 ++++ shared/src/main/scala/mlscript/syntax.scala | 2 +- shared/src/test/diff/mlscript/Basics.mls | 2 +- .../src/test/diff/mlscript/ByNameByValue.mls | 4 +- shared/src/test/diff/mlscript/MultiArgs.mls | 8 +-- shared/src/test/diff/mlscript/Ops.mls | 10 ++-- shared/src/test/diff/nu/AbstractClasses.mls | 2 +- shared/src/test/diff/nu/BadBlocks.mls | 2 +- shared/src/test/diff/nu/LamPatterns.mls | 2 +- shared/src/test/diff/nu/OverrideShorthand.mls | 4 +- shared/src/test/diff/nu/RightAssocOps.mls | 6 +-- shared/src/test/diff/ucs/LeadingAnd.mls | 4 +- shared/src/test/diff/ucs/SplitOps.mls | 4 +- 18 files changed, 95 insertions(+), 86 deletions(-) diff --git a/compiler/shared/test/diff/LambLift.mls b/compiler/shared/test/diff/LambLift.mls index bbfea08e3..ec08d4f08 100644 --- a/compiler/shared/test/diff/LambLift.mls +++ b/compiler/shared/test/diff/LambLift.mls @@ -10,7 +10,7 @@ fun foo() = local(1) foo() //│ Parsed: -//│ 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())))) +//│ 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(_,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(_,Var(x))), (None,Fld(_,App(Var(foo),Tup(List())))))))))))), Sel(Bra(false,App(NuNew(Var(Foo)),Tup(List()))),Var(bar))))))), App(Var(local),Tup(List((None,Fld(_,IntLit(1))))))))))), App(Var(foo),Tup(List())))) //│ Lifted: //│ TypingUnit { //│ class Foo$1([x,]) {fun bar = () => +((this).x, foo$1(),)} @@ -28,7 +28,7 @@ fun foo(f) = f(1) foo(x => x+1) //│ Parsed: -//│ 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)))))))))))))) +//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(f))))),Blk(List(App(Var(f),Tup(List((None,Fld(_,IntLit(1))))))))))), App(Var(foo),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1)))))))))))))) //│ Lifted: //│ TypingUnit { //│ class Lambda1$2$1([]) {fun apply = (x,) => +(x, 1,)} @@ -46,7 +46,7 @@ fun foo(x) = bar(y => y+x) foo(1) //│ Parsed: -//│ 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)))))))) +//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(NuFunDef(Some(false),Var(bar),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(f))))),Blk(List(App(Var(f),Tup(List((None,Fld(_,Var(x))))))))))), App(Var(bar),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(y))))),App(Var(+),Tup(List((None,Fld(_,Var(y))), (None,Fld(_,Var(x))))))))))))))))), App(Var(foo),Tup(List((None,Fld(_,IntLit(1)))))))) //│ Lifted: //│ TypingUnit { //│ class Lambda1$3$1([x,]) {fun apply = (y,) => +(y, (this).x,)} @@ -68,7 +68,7 @@ fun app(a) = foo(z => a.bar(z)) app(new A(1)) //│ Parsed: -//│ 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))))))))))))) +//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(f))))),Blk(List(App(Var(f),Tup(List((None,Fld(_,IntLit(1))))))))))), NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((Some(Var(y)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(z))))),App(Var(+),Tup(List((None,Fld(_,Var(y))), (None,Fld(_,Var(z)))))))))))), NuFunDef(None,Var(app),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(a))))),Blk(List(App(Var(foo),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(z))))),App(Sel(Var(a),Var(bar)),Tup(List((None,Fld(_,Var(z))))))))))))))))), App(Var(app),Tup(List((None,Fld(_,App(NuNew(Var(A)),Tup(List((None,Fld(_,IntLit(1))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1([y: Int,]) {fun bar = (z,) => +((this).y, z,)} diff --git a/compiler/shared/test/diff/LiftType.mls b/compiler/shared/test/diff/LiftType.mls index 0d8ea8eaf..4f2bebe4d 100644 --- a/compiler/shared/test/diff/LiftType.mls +++ b/compiler/shared/test/diff/LiftType.mls @@ -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(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))))))))))) +//│ 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(_,Lam(Tup(List((None,Fld(_,Var(A))))),Var(A)))))),Asc(App(Var(f),Tup(List((None,Fld(_,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,]) {} @@ -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(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)))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(CTX),List(),Some(Tup(List((None,Fld(_,Var(x))), (None,Fld(_,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(_,Tup(List((None,Fld(_,Var(A))), (None,Fld(_,Var(B))))))))),Asc(Tup(List((None,Fld(_,Sel(Var(any),Var(_2)))), (None,Fld(_,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} @@ -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(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)))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(CTX),List(),Some(Tup(List((None,Fld(_,Var(x))), (None,Fld(_,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(_,Bra(true,Rcd(List((Var(p1),Fld(_,Var(A))), (Var(p2),Fld(_,Var(B)))))))))),Asc(Tup(List((None,Fld(_,Sel(Var(any),Var(p2)))), (None,Fld(_,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} @@ -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(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)))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(CTX),List(),Some(Tup(List((None,Fld(_,Var(x))), (None,Fld(_,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(_,Tup(List((None,Fld(_,Var(A))), (None,Fld(_,TyApp(Var(B),List(TypeName(A))))))))))),Asc(Tup(List((None,Fld(_,Var(any))), (None,Fld(_,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} @@ -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(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))))))))))))) +//│ 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(_,Var(x))), (None,Fld(_,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(_,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. //│ diff --git a/compiler/shared/test/diff/Lifter.mls b/compiler/shared/test/diff/Lifter.mls index d55d43034..a1eb51a20 100644 --- a/compiler/shared/test/diff/Lifter.mls +++ b/compiler/shared/test/diff/Lifter.mls @@ -28,7 +28,7 @@ class A(x) { //│ |#class| |A|(|x|)| |{|→|#class| |B|(|y|)| |{|→|#fun| |getX| |#=| |x|↵|#fun| |getB1| |#=| |B1|(|y|)|↵|#class| |C|(|z|)| |{|→|#fun| |inc|(||)| |#=| |x| |+| |1|↵|#fun| |getY| |#=| |y|↵|#fun| |getA| |#=| |A|(|z|)|↵|#fun| |getB|(|w|)| |#=| |B|(|w|)|↵|#fun| |getC| |#=| |#new| |C|(|inc|(||)|)|↵|#fun| |getSelf| |#=| |this|←|↵|}|←|↵|}|↵|#class| |B1|(|y|)| |{|→|#fun| |getX| |#=| |x|↵|#fun| |getY| |#=| |y|↵|#fun| |getB| |#=| |#new| |B|(|y|)|↵|#fun| |getB1| |#=| |#new| |B1|(|y|)|←|↵|}|↵|#fun| |getB| |#=| |#new| |B|(|x|)|↵|#fun| |getB2|(|y|)| |#=| |B1|(|y|)|↵|#fun| |getB3|(|z|)| |#=| |getB2|(|z|)|↵|#fun| |getA| |#=| |A|(|x|)|←|↵|}| //│ Parsed: {class A(x,) {class B(y,) {fun getX = x; fun getB1 = B1(y,); class C(z,) {fun inc = () => +(x, 1,); fun getY = y; fun getA = A(z,); fun getB = (w,) => B(w,); fun getC = (new C)(inc(),); fun getSelf = this}}; class B1(y,) {fun getX = x; fun getY = y; fun getB = (new B)(y,); fun getB1 = (new B1)(y,)}; fun getB = (new B)(x,); fun getB2 = (y,) => B1(y,); fun getB3 = (z,) => getB2(z,); fun getA = A(x,)}} //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(getX),None,List(),Left(Var(x))), NuFunDef(None,Var(getB1),None,List(),Left(App(Var(B1),Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))))), NuTypeDef(Cls,TypeName(C),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(z)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(inc),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))))), NuFunDef(None,Var(getY),None,List(),Left(Var(y))), NuFunDef(None,Var(getA),None,List(),Left(App(Var(A),Tup(List((None,Fld(FldFlags(false,false,false),Var(z)))))))), NuFunDef(None,Var(getB),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(w))))),App(Var(B),Tup(List((None,Fld(FldFlags(false,false,false),Var(w))))))))), NuFunDef(None,Var(getC),None,List(),Left(App(NuNew(Var(C)),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(inc),Tup(List()))))))))), NuFunDef(None,Var(getSelf),None,List(),Left(Var(this))))))))), NuTypeDef(Cls,TypeName(B1),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(getX),None,List(),Left(Var(x))), NuFunDef(None,Var(getY),None,List(),Left(Var(y))), NuFunDef(None,Var(getB),None,List(),Left(App(NuNew(Var(B)),Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))))), NuFunDef(None,Var(getB1),None,List(),Left(App(NuNew(Var(B1)),Tup(List((None,Fld(FldFlags(false,false,false),Var(y))))))))))), NuFunDef(None,Var(getB),None,List(),Left(App(NuNew(Var(B)),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))), NuFunDef(None,Var(getB2),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(y))))),App(Var(B1),Tup(List((None,Fld(FldFlags(false,false,false),Var(y))))))))), NuFunDef(None,Var(getB3),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(z))))),App(Var(getB2),Tup(List((None,Fld(FldFlags(false,false,false),Var(z))))))))), NuFunDef(None,Var(getA),None,List(),Left(App(Var(A),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(_,Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),Some(Tup(List((None,Fld(_,Var(y)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(getX),None,List(),Left(Var(x))), NuFunDef(None,Var(getB1),None,List(),Left(App(Var(B1),Tup(List((None,Fld(_,Var(y)))))))), NuTypeDef(Cls,TypeName(C),List(),Some(Tup(List((None,Fld(_,Var(z)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(inc),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1))))))))), NuFunDef(None,Var(getY),None,List(),Left(Var(y))), NuFunDef(None,Var(getA),None,List(),Left(App(Var(A),Tup(List((None,Fld(_,Var(z)))))))), NuFunDef(None,Var(getB),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(w))))),App(Var(B),Tup(List((None,Fld(_,Var(w))))))))), NuFunDef(None,Var(getC),None,List(),Left(App(NuNew(Var(C)),Tup(List((None,Fld(_,App(Var(inc),Tup(List()))))))))), NuFunDef(None,Var(getSelf),None,List(),Left(Var(this))))))))), NuTypeDef(Cls,TypeName(B1),List(),Some(Tup(List((None,Fld(_,Var(y)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(getX),None,List(),Left(Var(x))), NuFunDef(None,Var(getY),None,List(),Left(Var(y))), NuFunDef(None,Var(getB),None,List(),Left(App(NuNew(Var(B)),Tup(List((None,Fld(_,Var(y)))))))), NuFunDef(None,Var(getB1),None,List(),Left(App(NuNew(Var(B1)),Tup(List((None,Fld(_,Var(y))))))))))), NuFunDef(None,Var(getB),None,List(),Left(App(NuNew(Var(B)),Tup(List((None,Fld(_,Var(x)))))))), NuFunDef(None,Var(getB2),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(y))))),App(Var(B1),Tup(List((None,Fld(_,Var(y))))))))), NuFunDef(None,Var(getB3),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(z))))),App(Var(getB2),Tup(List((None,Fld(_,Var(z))))))))), NuFunDef(None,Var(getA),None,List(),Left(App(Var(A),Tup(List((None,Fld(_,Var(x))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2_C$4([par$A$1_B$2, z, x,]) { @@ -68,7 +68,7 @@ class A(x) { //│ |#class| |A|(|x|)| |{|→|#class| |B|(|y|)| |{|→|#class| |C|(|z|)| |{|→|#fun| |sum| |#=| |x| |+| |y| |+| |z|←|↵|}|←|↵|}|←|↵|}| //│ Parsed: {class A(x,) {class B(y,) {class C(z,) {fun sum = +(+(x, y,), z,)}}}} //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(C),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(z)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(sum),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))))), (None,Fld(FldFlags(false,false,false),Var(z))))))))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(_,Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),Some(Tup(List((None,Fld(_,Var(y)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(C),List(),Some(Tup(List((None,Fld(_,Var(z)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(sum),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))))), (None,Fld(_,Var(z))))))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2_C$3([par$A$1_B$2, z, x,]) { @@ -108,7 +108,7 @@ new C{ //│ |#class| |A|(|x|)| |{|→|#class| |B|{|→|#fun| |foo| |#=| |1|↵|#fun| |bar| |#=| |11|←|↵|}|↵|#fun| |getB| |#=| |#new| |B|{|→|#fun| |foo| |#=| |2|↵|#fun| |bar| |#=| |12|←|↵|}|↵|#fun| |bar| |#=| |13|←|↵|}|↵|#class| |C|#:| |A|{|→|#fun| |getB| |#=| |#new| |B|{|→|#fun| |foo| |#=| |3|↵|#fun| |bar| |#=| |14|←|↵|}|↵|#fun| |bar| |#=| |15|←|↵|}|↵|#new| |C|{|→|#fun| |getB| |#=| |#new| |B|{|→|#fun| |foo| |#=| |4|↵|#fun| |bar| |#=| |16|←|↵|}|↵|#fun| |bar| |#=| |17|←|↵|}| //│ Parsed: {class A(x,) {class B {fun foo = 1; fun bar = 11}; fun getB = new B { ‹fun foo = 2; fun bar = 12› }; fun bar = 13}; class C: A {fun getB = new B { ‹fun foo = 3; fun bar = 14› }; fun bar = 15}; new C { ‹fun getB = new B { ‹fun foo = 4; fun bar = 16› }; fun bar = 17› }} //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(1))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(11)))))), NuFunDef(None,Var(getB),None,List(),Left(Rft(NuNew(Var(B)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(2))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(12)))))))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(13)))))), NuTypeDef(Cls,TypeName(C),List(),None,None,Some(TypeName(A)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(getB),None,List(),Left(Rft(NuNew(Var(B)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(3))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(14)))))))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(15)))))), Rft(NuNew(Var(C)),TypingUnit(List(NuFunDef(None,Var(getB),None,List(),Left(Rft(NuNew(Var(B)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(4))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(16)))))))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(17)))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(_,Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(1))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(11)))))), NuFunDef(None,Var(getB),None,List(),Left(Rft(NuNew(Var(B)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(2))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(12)))))))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(13)))))), NuTypeDef(Cls,TypeName(C),List(),None,None,Some(TypeName(A)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(getB),None,List(),Left(Rft(NuNew(Var(B)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(3))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(14)))))))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(15)))))), Rft(NuNew(Var(C)),TypingUnit(List(NuFunDef(None,Var(getB),None,List(),Left(Rft(NuNew(Var(B)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(4))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(16)))))))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(17)))))))) //│ Lifted: //│ Lifting failed: mlscript.codegen.CodeGenError: Cannot find type B. Class values are not supported in lifter. //│ @@ -125,7 +125,7 @@ class Parent(x) { //│ |#class| |Parent|‹|T|,| |U|,| |V|›|(|x|)| |{| |→|#fun| |foo|(|x|#:| |Int|)|#:| |T| |#=| |x|+|1|↵|#class| |Inner|‹|W|›|(|y|#:| |Int|)|{|→|#fun| |bar|(|z|#:| |U|)| |#=| |foo|(|y|)|↵|#fun| |boo|(|z|#:| |W|)| |#=| |z|←|↵|}|←|↵|}| //│ Parsed: {class Parent‹T, U, V›(x,) {fun foo = (x: Int,) => +(x, 1,) : T; class Inner‹W›(y: Int,) {fun bar = (z: U,) => foo(y,); fun boo = (z: W,) => z}}} //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Parent),List((None,TypeName(T)), (None,TypeName(U)), (None,TypeName(V))),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(Int))))),Asc(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))),TypeName(T))))), NuTypeDef(Cls,TypeName(Inner),List((None,TypeName(W))),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((Some(Var(z)),Fld(FldFlags(false,false,false),Var(U))))),App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),Var(y))))))))), NuFunDef(None,Var(boo),None,List(),Left(Lam(Tup(List((Some(Var(z)),Fld(FldFlags(false,false,false),Var(W))))),Var(z)))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Parent),List((None,TypeName(T)), (None,TypeName(U)), (None,TypeName(V))),Some(Tup(List((None,Fld(_,Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(_,Var(Int))))),Asc(App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1)))))),TypeName(T))))), NuTypeDef(Cls,TypeName(Inner),List((None,TypeName(W))),Some(Tup(List((Some(Var(y)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(Lam(Tup(List((Some(Var(z)),Fld(_,Var(U))))),App(Var(foo),Tup(List((None,Fld(_,Var(y))))))))), NuFunDef(None,Var(boo),None,List(),Left(Lam(Tup(List((Some(Var(z)),Fld(_,Var(W))))),Var(z)))))))))))) //│ Lifted: //│ TypingUnit { //│ class Parent$1_Inner$2[W,U]([par$Parent$1, y: Int,]) { @@ -148,7 +148,7 @@ class A(x: Int): ({a1: Int} & B & D(x)) { //│ |#class| |B|‹|T|›| |{||}|↵|#class| |C| |{||}|↵|#class| |D|(|y|#:| |Int|)| |{||}|↵|#class| |A|‹|T|,| |U|›|(|x|#:| |Int|)|#:| |(|{|a1|#:| |Int|}| |&| |B|‹|T|›| |&| |D|(|x|)|)| |{|→|#fun| |getA|(||)| |#=| |#new| |C|{|→|#fun| |foo|(|x|#:| |T|)| |#=| |x|←|↵|}|←|↵|}| //│ Parsed: {class B‹T› {}; class C {}; class D(y: Int,) {}; class A‹T, U›(x: Int,): {a1: Int} & B[T] & D[x] {fun getA = () => new C { ‹fun foo = (x: T,) => x› }}} //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(B),List((None,TypeName(T))),None,None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(C),List(),None,None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(D),List(),Some(Tup(List((Some(Var(y)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(A),List((None,TypeName(T)), (None,TypeName(U))),Some(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(Int)))))),None,Some(Inter(Inter(Record(List((Var(a1),Field(None,TypeName(Int))))),AppliedType(TypeName(B),List(TypeName(T)))),AppliedType(TypeName(D),List(TypeName(x))))),List(),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(Lam(Tup(List()),Rft(NuNew(Var(C)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(T))))),Var(x))))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(B),List((None,TypeName(T))),None,None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(C),List(),None,None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(D),List(),Some(Tup(List((Some(Var(y)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(A),List((None,TypeName(T)), (None,TypeName(U))),Some(Tup(List((Some(Var(x)),Fld(_,Var(Int)))))),None,Some(Inter(Inter(Record(List((Var(a1),Field(None,TypeName(Int))))),AppliedType(TypeName(B),List(TypeName(T)))),AppliedType(TypeName(D),List(TypeName(x))))),List(),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(Lam(Tup(List()),Rft(NuNew(Var(C)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(_,Var(T))))),Var(x))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class B$1[T]([]) {} @@ -170,7 +170,7 @@ class A(x: Int) extends {a1: Int}, B, D(x){ //│ |#class| |B|‹|T|›| |{||}|↵|#class| |C| |{||}|↵|#class| |D|(|y|#:| |Int|)| |{||}|↵|#class| |A|‹|T|,| |U|›|(|x|#:| |Int|)| |#extends| |{|a1|#:| |Int|}|,| |B|‹|T|›|,| |D|(|x|)|{|→|#fun| |getA|(||)| |#=| |#new| |C|{|→|#fun| |foo|(|x|)| |#=| |x|←|↵|}|←|↵|}| //│ Parsed: {class B‹T› {}; class C {}; class D(y: Int,) {}; class A‹T, U›(x: Int,): '{' {a1: Int} '}', B‹T›, D(x,) {fun getA = () => new C { ‹fun foo = (x,) => x› }}} //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(B),List((None,TypeName(T))),None,None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(C),List(),None,None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(D),List(),Some(Tup(List((Some(Var(y)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(A),List((None,TypeName(T)), (None,TypeName(U))),Some(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(Bra(true,Rcd(List((Var(a1),Fld(FldFlags(false,false,false),Var(Int)))))), TyApp(Var(B),List(TypeName(T))), App(Var(D),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))))),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(Lam(Tup(List()),Rft(NuNew(Var(C)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Var(x))))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(B),List((None,TypeName(T))),None,None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(C),List(),None,None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(D),List(),Some(Tup(List((Some(Var(y)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(A),List((None,TypeName(T)), (None,TypeName(U))),Some(Tup(List((Some(Var(x)),Fld(_,Var(Int)))))),None,None,List(Bra(true,Rcd(List((Var(a1),Fld(_,Var(Int)))))), TyApp(Var(B),List(TypeName(T))), App(Var(D),Tup(List((None,Fld(_,Var(x))))))),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(Lam(Tup(List()),Rft(NuNew(Var(C)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Var(x))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class B$1[T]([]) {} @@ -190,7 +190,7 @@ class Child(x): ({ age: T } & { name: String}) { //│ |#class| |Child|‹|T|,| |U|›|(|x|)|#:| |(|{| |age|#:| |T| |}| |&| |{| |name|#:| |String|}|)| |{|→|#class| |Inner|{|→|#fun| |foo| |#=| |age|←|↵|}|↵|#fun| |bar| |#=| |age|↵|#fun| |boo| |#=| |#new| |Inner|←|↵|}| //│ Parsed: {class Child‹T, U›(x,): {age: T} & {name: String} {class Inner {fun foo = age}; fun bar = age; fun boo = new Inner}} //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Child),List((None,TypeName(T)), (None,TypeName(U))),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,Some(Inter(Record(List((Var(age),Field(None,TypeName(T))))),Record(List((Var(name),Field(None,TypeName(String))))))),List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(Inner),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Var(age)))))), NuFunDef(None,Var(bar),None,List(),Left(Var(age))), NuFunDef(None,Var(boo),None,List(),Left(NuNew(Var(Inner))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Child),List((None,TypeName(T)), (None,TypeName(U))),Some(Tup(List((None,Fld(_,Var(x)))))),None,Some(Inter(Record(List((Var(age),Field(None,TypeName(T))))),Record(List((Var(name),Field(None,TypeName(String))))))),List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(Inner),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Var(age)))))), NuFunDef(None,Var(bar),None,List(),Left(Var(age))), NuFunDef(None,Var(boo),None,List(),Left(NuNew(Var(Inner))))))))) //│ Lifted: //│ TypingUnit { //│ class Child$1_Inner$2([par$Child$1, age,]) {fun foo = () => (this).age} @@ -213,7 +213,7 @@ new A(0) { //│ |#class| |A|(|x|#:| |Int|)| |{|→|#fun| |getA|#:| |Int| |#=| |0|↵|#fun| |getA1| |#=| |1|←|↵|}|↵|#new| |A|(|0|)| |{|→|#fun| |getA| |#=| |3|↵|#fun| |getA2| |#=| |2|←|↵|}| //│ Parsed: {class A(x: Int,) {fun getA = 0 : Int; fun getA1 = 1}; (new A)(0,) { ‹fun getA = 3; fun getA2 = 2› }} //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(Asc(IntLit(0),TypeName(Int)))), NuFunDef(None,Var(getA1),None,List(),Left(IntLit(1)))))), Rft(App(NuNew(Var(A)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))),TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(IntLit(3))), NuFunDef(None,Var(getA2),None,List(),Left(IntLit(2)))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((Some(Var(x)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(Asc(IntLit(0),TypeName(Int)))), NuFunDef(None,Var(getA1),None,List(),Left(IntLit(1)))))), Rft(App(NuNew(Var(A)),Tup(List((None,Fld(_,IntLit(0)))))),TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(IntLit(3))), NuFunDef(None,Var(getA2),None,List(),Left(IntLit(2)))))))) //│ Lifted: //│ TypingUnit { //│ class A$1([x: Int,]) {fun getA = () => 0 : Int; fun getA1 = () => 1} @@ -234,7 +234,7 @@ new A(1) { //│ |#class| |A|(|x|)| |{|→|#class| |B|(|y|)| |{| |}|←|↵|}|↵|#new| |A|(|1|)| |{|→|#fun| |getB| |#=| |#new| |B|(|2|)|{|→|#fun| |getB| |#=| |#new| |B|(|3|)|←|↵|}|←|↵|}| //│ Parsed: {class A(x,) {class B(y,) {}}; (new A)(1,) { ‹fun getB = (new B)(2,) { ‹fun getB = (new B)(3,)› }› }} //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))),None,None,List(),None,None,TypingUnit(List()))))), Rft(App(NuNew(Var(A)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))),TypingUnit(List(NuFunDef(None,Var(getB),None,List(),Left(Rft(App(NuNew(Var(B)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))),TypingUnit(List(NuFunDef(None,Var(getB),None,List(),Left(App(NuNew(Var(B)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(3)))))))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(_,Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),Some(Tup(List((None,Fld(_,Var(y)))))),None,None,List(),None,None,TypingUnit(List()))))), Rft(App(NuNew(Var(A)),Tup(List((None,Fld(_,IntLit(1)))))),TypingUnit(List(NuFunDef(None,Var(getB),None,List(),Left(Rft(App(NuNew(Var(B)),Tup(List((None,Fld(_,IntLit(2)))))),TypingUnit(List(NuFunDef(None,Var(getB),None,List(),Left(App(NuNew(Var(B)),Tup(List((None,Fld(_,IntLit(3)))))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1, y,]) {} @@ -267,7 +267,7 @@ new B{ //│ |#class| |A| |{|→|#fun| |getA| |#=| |0|↵|#fun| |funcA| |#=| |10|←|↵|}|↵|#class| |B|#:| |A|{|→|#fun| |getA| |#=| |1|↵|#fun| |funcB| |#=| |11|←|↵|}|↵|#new| |A|↵|#new| |B|↵|#fun| |f|(|x|)| |#=| |#if| |x| |is| |A| |#then| |0| |#else| |1|↵|f|(|#new| |A|{|→|#fun| |getA| |#=| |2|←|↵|}|)|↵|#new| |B|{|→|#fun| |getA| |#=| |funcB|←|↵|}| //│ Parsed: {class A {fun getA = 0; fun funcA = 10}; class B: A {fun getA = 1; fun funcB = 11}; new A; new B; fun f = (x,) => if (is(x, A,)) then 0 else 1; f(new A { ‹fun getA = 2› },); new B { ‹fun getA = funcB› }} //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(IntLit(0))), NuFunDef(None,Var(funcA),None,List(),Left(IntLit(10)))))), NuTypeDef(Cls,TypeName(B),List(),None,None,Some(TypeName(A)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(IntLit(1))), NuFunDef(None,Var(funcB),None,List(),Left(IntLit(11)))))), NuNew(Var(A)), NuNew(Var(B)), NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),If(IfThen(App(Var(is),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(A)))))),IntLit(0)),Some(IntLit(1)))))), App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(IntLit(2))))))))))), Rft(NuNew(Var(B)),TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(Var(funcB)))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(IntLit(0))), NuFunDef(None,Var(funcA),None,List(),Left(IntLit(10)))))), NuTypeDef(Cls,TypeName(B),List(),None,None,Some(TypeName(A)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(IntLit(1))), NuFunDef(None,Var(funcB),None,List(),Left(IntLit(11)))))), NuNew(Var(A)), NuNew(Var(B)), NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),If(IfThen(App(Var(is),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(A)))))),IntLit(0)),Some(IntLit(1)))))), App(Var(f),Tup(List((None,Fld(_,Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(IntLit(2))))))))))), Rft(NuNew(Var(B)),TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(Var(funcB)))))))) //│ Lifted: //│ TypingUnit { //│ class A$1([]) {fun getA = () => 0; fun funcA = () => 10} @@ -409,7 +409,7 @@ let x = new A{ //│ |#class| |A|(|x|)| |{|→|#fun| |foo| |#=| |0|↵|#fun| |bar| |#=| |x|←|↵|}|↵|#let| |x| |#=| |#new| |A|{|→|#fun| |foo| |#=| |1|↵|#fun| |newFun| |#=| |2|↵|#fun| |bar| |#=| |#new| |A|(|foo|)|{|→|#fun| |foo| |#=| |bar| |+| |1|↵|#fun| |bar2| |#=| |newFun| |+| |1|←|↵|}|←|↵|}| //│ Parsed: {class A(x,) {fun foo = 0; fun bar = x}; let x = new A { ‹fun foo = 1; fun newFun = 2; fun bar = (new A)(foo,) { ‹fun foo = +(bar, 1,); fun bar2 = +(newFun, 1,)› }› }} //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(0))), NuFunDef(None,Var(bar),None,List(),Left(Var(x)))))), NuFunDef(Some(false),Var(x),None,List(),Left(Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(1))), NuFunDef(None,Var(newFun),None,List(),Left(IntLit(2))), NuFunDef(None,Var(bar),None,List(),Left(Rft(App(NuNew(Var(A)),Tup(List((None,Fld(FldFlags(false,false,false),Var(foo)))))),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(bar))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))))), NuFunDef(None,Var(bar2),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(newFun))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))))))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(_,Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(0))), NuFunDef(None,Var(bar),None,List(),Left(Var(x)))))), NuFunDef(Some(false),Var(x),None,List(),Left(Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(1))), NuFunDef(None,Var(newFun),None,List(),Left(IntLit(2))), NuFunDef(None,Var(bar),None,List(),Left(Rft(App(NuNew(Var(A)),Tup(List((None,Fld(_,Var(foo)))))),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,Var(bar))), (None,Fld(_,IntLit(1)))))))), NuFunDef(None,Var(bar2),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,Var(newFun))), (None,Fld(_,IntLit(1)))))))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1([x,]) {fun foo = () => 0; fun bar = () => (this).x} diff --git a/compiler/shared/test/diff/LifterBlks.mls b/compiler/shared/test/diff/LifterBlks.mls index f5e52e146..826dc8a9c 100644 --- a/compiler/shared/test/diff/LifterBlks.mls +++ b/compiler/shared/test/diff/LifterBlks.mls @@ -7,7 +7,7 @@ fun foo = //│ |#fun| |foo| |#=|→|print|(|"ok"|)|↵|print|(|"ko"|)|←| //│ Parsed: {fun foo = {print("ok",); print("ko",)}} //│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Blk(List(App(Var(print),Tup(List((None,Fld(FldFlags(false,false,false),StrLit(ok)))))), App(Var(print),Tup(List((None,Fld(FldFlags(false,false,false),StrLit(ko)))))))))))) +//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Blk(List(App(Var(print),Tup(List((None,Fld(_,StrLit(ok)))))), App(Var(print),Tup(List((None,Fld(_,StrLit(ko)))))))))))) //│ Lifted: //│ TypingUnit {fun foo$1 = () => {print("ok",); print("ko",)}} //│ @@ -19,7 +19,7 @@ class A{ //│ |#class| |A|{|→|#class| |B| |{||}|↵|#fun| |foo|(|x|#:| |B|)| |#=| |(|x| |#:| |B|)|←|↵|}| //│ Parsed: {class A {class B {}; fun foo = (x: B,) => '(' x : B ')'}} //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List())), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(B))))),Bra(false,Asc(Var(x),TypeName(B))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List())), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(_,Var(B))))),Bra(false,Asc(Var(x),TypeName(B))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1,]) {} @@ -41,7 +41,7 @@ fun foo = //│ |#fun| |foo| |#=|→|#let| |local|(|x|)| |#=|→|#class| |Foo| |{|→|#fun| |bar| |#=| |x| |+| |1|←|↵|}|↵|Foo|(||)|.bar|←|↵|print| |#of| |local|(|0|)| |+| |local|(|1|)|↵|print| |#of| |(|local| |#of| |0|)| |+| |local| |#of| |1|↵|#fun| |tmp| |#=| |1|↵|print| |#of| |local| |#of| |0| |+| |local| |#of| |1|↵|#fun| |tmp| |#=| |2|←| //│ Parsed: {fun foo = {let local = (x,) => {class Foo {fun bar = +(x, 1,)}; (Foo()).bar}; print(+(local(0,), local(1,),),); print(+('(' local(0,) ')', local(1,),),); fun tmp = 1; print(local(+(0, local(1,),),),); fun tmp = 2}} //│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(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),IntLit(1))))))))))), Sel(App(Var(Foo),Tup(List())),Var(bar))))))), App(Var(print),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(local),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))))), (None,Fld(FldFlags(false,false,false),App(Var(local),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))))))))))))), App(Var(print),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Bra(false,App(Var(local),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0))))))))), (None,Fld(FldFlags(false,false,false),App(Var(local),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))))))))))))), NuFunDef(None,Var(tmp),None,List(),Left(IntLit(1))), App(Var(print),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(local),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0))), (None,Fld(FldFlags(false,false,false),App(Var(local),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))))))))))))))))))))), NuFunDef(None,Var(tmp),None,List(),Left(IntLit(2))))))))) +//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Blk(List(NuFunDef(Some(false),Var(local),None,List(),Left(Lam(Tup(List((None,Fld(_,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(_,Var(x))), (None,Fld(_,IntLit(1))))))))))), Sel(App(Var(Foo),Tup(List())),Var(bar))))))), App(Var(print),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,App(Var(local),Tup(List((None,Fld(_,IntLit(0)))))))), (None,Fld(_,App(Var(local),Tup(List((None,Fld(_,IntLit(1)))))))))))))))), App(Var(print),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Bra(false,App(Var(local),Tup(List((None,Fld(_,IntLit(0))))))))), (None,Fld(_,App(Var(local),Tup(List((None,Fld(_,IntLit(1)))))))))))))))), NuFunDef(None,Var(tmp),None,List(),Left(IntLit(1))), App(Var(print),Tup(List((None,Fld(_,App(Var(local),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,IntLit(0))), (None,Fld(_,App(Var(local),Tup(List((None,Fld(_,IntLit(1))))))))))))))))))))), NuFunDef(None,Var(tmp),None,List(),Left(IntLit(2))))))))) //│ Lifted: //│ TypingUnit { //│ class Foo$1([x,]) {fun bar = () => +((this).x, 1,)} @@ -57,7 +57,7 @@ f(0) //│ |#class| |A|(|y|)|{||}|↵|#let| |f| |#=| |x| |#=>| |#new| |A|(|0|)|{|#fun| |bar| |#=| |x|+|y|}|↵|f|(|0|)| //│ Parsed: {class A(y,) {}; let f = (x,) => (new A)(0,) { ‹fun bar = +(x, y,)› }; f(0,)} //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))),None,None,List(),None,None,TypingUnit(List())), NuFunDef(Some(false),Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Rft(App(NuNew(Var(A)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))),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),Var(y)))))))))))))), App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(_,Var(y)))))),None,None,List(),None,None,TypingUnit(List())), NuFunDef(Some(false),Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Rft(App(NuNew(Var(A)),Tup(List((None,Fld(_,IntLit(0)))))),TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))))))))))), App(Var(f),Tup(List((None,Fld(_,IntLit(0)))))))) //│ Lifted: //│ TypingUnit { //│ class A$1([y,]) {} @@ -80,7 +80,7 @@ class A(x){ //│ |#class| |A|(|x|)|{|→|#fun| |w| |#=| |x|↵|#fun| |foo|(|y|)| |#=| |→|#class| |B|(|z|)|{|→|#fun| |bar| |#=| |x|+|y|+|z|←|↵|}|↵|#new| |B|(|0|)|{|→|#fun| |bar| |#=| |w|+|y|+|z|←|↵|}|←|←|↵|}| //│ Parsed: {class A(x,) {fun w = x; fun foo = (y,) => {class B(z,) {fun bar = +(+(x, y,), z,)}; (new B)(0,) { ‹fun bar = +(+(w, y,), z,)› }}}} //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(w),None,List(),Left(Var(x))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(y))))),Blk(List(NuTypeDef(Cls,TypeName(B),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(z)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))))), (None,Fld(FldFlags(false,false,false),Var(z))))))))))), Rft(App(NuNew(Var(B)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))),TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(w))), (None,Fld(FldFlags(false,false,false),Var(y)))))))), (None,Fld(FldFlags(false,false,false),Var(z))))))))))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(_,Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(w),None,List(),Left(Var(x))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(y))))),Blk(List(NuTypeDef(Cls,TypeName(B),List(),Some(Tup(List((None,Fld(_,Var(z)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))))), (None,Fld(_,Var(z))))))))))), Rft(App(NuNew(Var(B)),Tup(List((None,Fld(_,IntLit(0)))))),TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(w))), (None,Fld(_,Var(y)))))))), (None,Fld(_,Var(z))))))))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1, z, y,]) { @@ -111,7 +111,7 @@ fun f(x,y,z) = //│ |#fun| |f|(|x|,|y|,|z|)| |#=| |→|#class| |A|{|→|#fun| |foo| |#=| |#new| |B|↵|#fun| |bar1| |#=| |x|←|↵|}|↵|#class| |B|{|→|#fun| |foo| |#=| |#new| |A|↵|#fun| |bar2| |#=| |y|←|↵|}|↵|#class| |C| |#extends| |A|,| |B| |{|→|#fun| |bar| |#=| |bar1| |+| |bar2|←|↵|}|←| //│ Parsed: {fun f = (x, y, z,) => {class A {fun foo = new B; fun bar1 = x}; class B {fun foo = new A; fun bar2 = y}; class C: A, B {fun bar = +(bar1, bar2,)}}} //│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y))), (None,Fld(FldFlags(false,false,false),Var(z))))),Blk(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(NuNew(Var(B)))), NuFunDef(None,Var(bar1),None,List(),Left(Var(x)))))), NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(NuNew(Var(A)))), NuFunDef(None,Var(bar2),None,List(),Left(Var(y)))))), NuTypeDef(Cls,TypeName(C),List(),None,None,None,List(Var(A), Var(B)),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(bar1))), (None,Fld(FldFlags(false,false,false),Var(bar2)))))))))))))))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y))), (None,Fld(_,Var(z))))),Blk(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(NuNew(Var(B)))), NuFunDef(None,Var(bar1),None,List(),Left(Var(x)))))), NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(NuNew(Var(A)))), NuFunDef(None,Var(bar2),None,List(),Left(Var(y)))))), NuTypeDef(Cls,TypeName(C),List(),None,None,None,List(Var(A), Var(B)),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,Var(bar1))), (None,Fld(_,Var(bar2)))))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1([x, y,]) { @@ -142,7 +142,7 @@ fun f(x,y,z) = //│ |#fun| |f|(|x|,|y|,|z|)| |#=| |→|#class| |C|{|→|#class| |A|{|→|#fun| |foo| |#=| |#new| |B|↵|#fun| |bar1| |#=| |x|←|↵|}|↵|#class| |B|{|→|#fun| |foo| |#=| |#new| |A|↵|#fun| |bar2| |#=| |y|←|↵|}|↵|#fun| |boo| |#=| |(|#new| |A|)|.bar1| |+| |B|(||)|.bar2| |+| |z|←|↵|}|←| //│ Parsed: {fun f = (x, y, z,) => {class C {class A {fun foo = new B; fun bar1 = x}; class B {fun foo = new A; fun bar2 = y}; fun boo = +(+(('(' new A ')').bar1, (B()).bar2,), z,)}}} //│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y))), (None,Fld(FldFlags(false,false,false),Var(z))))),Blk(List(NuTypeDef(Cls,TypeName(C),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(NuNew(Var(B)))), NuFunDef(None,Var(bar1),None,List(),Left(Var(x)))))), NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(NuNew(Var(A)))), NuFunDef(None,Var(bar2),None,List(),Left(Var(y)))))), NuFunDef(None,Var(boo),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Sel(Bra(false,NuNew(Var(A))),Var(bar1)))), (None,Fld(FldFlags(false,false,false),Sel(App(Var(B),Tup(List())),Var(bar2))))))))), (None,Fld(FldFlags(false,false,false),Var(z)))))))))))))))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y))), (None,Fld(_,Var(z))))),Blk(List(NuTypeDef(Cls,TypeName(C),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(NuNew(Var(B)))), NuFunDef(None,Var(bar1),None,List(),Left(Var(x)))))), NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(NuNew(Var(A)))), NuFunDef(None,Var(bar2),None,List(),Left(Var(y)))))), NuFunDef(None,Var(boo),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Sel(Bra(false,NuNew(Var(A))),Var(bar1)))), (None,Fld(_,Sel(App(Var(B),Tup(List())),Var(bar2))))))))), (None,Fld(_,Var(z)))))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class C$1_A$2([par$C$1,]) { @@ -168,7 +168,7 @@ fun f(y) = //│ |#fun| |f|(|y|)| |#=|→|#let| |g|(|x|)| |#=| |x| |+| |y| |+| |1|↵|#class| |Foo|(|x|)| |{|→|#fun| |h| |#=| |g|(|x|)|←|↵|}|←| //│ Parsed: {fun f = (y,) => {let g = (x,) => +(+(x, y,), 1,); class Foo(x,) {fun h = g(x,)}}} //│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(y))))),Blk(List(NuFunDef(Some(false),Var(g),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))))), NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(h),None,List(),Left(App(Var(g),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))))))))))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(y))))),Blk(List(NuFunDef(Some(false),Var(g),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(+),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))))), (None,Fld(_,IntLit(1))))))))), NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((None,Fld(_,Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(h),None,List(),Left(App(Var(g),Tup(List((None,Fld(_,Var(x)))))))))))))))))) //│ Lifted: //│ TypingUnit { //│ class Foo$1([x, y,]) {fun h = () => g$2((this).x, y,)} @@ -180,7 +180,7 @@ fun f(y) = //│ | |Foo|(|1|)|.h| //│ Parsed: {(Foo(1,)).h} //│ Parsed: -//│ TypingUnit(List(Sel(App(Var(Foo),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))),Var(h)))) +//│ TypingUnit(List(Sel(App(Var(Foo),Tup(List((None,Fld(_,IntLit(1)))))),Var(h)))) //│ Lifted: //│ TypingUnit {Code(List((Foo(1,)).h))} //│ @@ -188,7 +188,7 @@ fun f(y) = //│ | |Foo|(|x|)|.h| //│ Parsed: {(Foo(x,)).h} //│ Parsed: -//│ TypingUnit(List(Sel(App(Var(Foo),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),Var(h)))) +//│ TypingUnit(List(Sel(App(Var(Foo),Tup(List((None,Fld(_,Var(x)))))),Var(h)))) //│ Lifted: //│ TypingUnit {Code(List((Foo(x,)).h))} //│ @@ -204,7 +204,7 @@ fun f(x) = //│ |#fun| |f|(|x|)| |#=|→|#let| |g|(|x|)| |#=| |→|#let| |h|(|x|)| |#=| |x| |+| |2|↵|Foo|(|h|(|x|)|,| |x|)|.bar|←|↵|#class| |Foo|(|x|,| |y|)| |{|→|#fun| |bar| |#=| |g|(|x|)|+|y|←|↵|}|↵|Foo|(|x|,| |x|)|.bar|←| //│ Parsed: {fun f = (x,) => {let g = (x,) => {let h = (x,) => +(x, 2,); (Foo(h(x,), x,)).bar}; class Foo(x, y,) {fun bar = +(g(x,), y,)}; (Foo(x, x,)).bar}} //│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(NuFunDef(Some(false),Var(g),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(NuFunDef(Some(false),Var(h),None,List(),Left(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(2))))))))), Sel(App(Var(Foo),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(h),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))), (None,Fld(FldFlags(false,false,false),Var(x)))))),Var(bar))))))), NuTypeDef(Cls,TypeName(Foo),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(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(g),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))), (None,Fld(FldFlags(false,false,false),Var(y))))))))))), Sel(App(Var(Foo),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(x)))))),Var(bar))))))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(NuFunDef(Some(false),Var(g),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(NuFunDef(Some(false),Var(h),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(2))))))))), Sel(App(Var(Foo),Tup(List((None,Fld(_,App(Var(h),Tup(List((None,Fld(_,Var(x)))))))), (None,Fld(_,Var(x)))))),Var(bar))))))), NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,App(Var(g),Tup(List((None,Fld(_,Var(x)))))))), (None,Fld(_,Var(y))))))))))), Sel(App(Var(Foo),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(x)))))),Var(bar))))))))) //│ Lifted: //│ TypingUnit { //│ class Foo$1([x, y,]) {fun bar = () => +(g$2((this).x,), (this).y,)} @@ -218,7 +218,7 @@ class Foo(x, y) extends Bar(y, x), Baz(x + y) //│ |#class| |Foo|(|x|,| |y|)| |#extends| |Bar|(|y|,| |x|)|,| |Baz|(|x| |+| |y|)| //│ Parsed: {class Foo(x, y,): Bar(y, x,), Baz(+(x, y,),) {}} //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))),None,None,List(App(Var(Bar),Tup(List((None,Fld(FldFlags(false,false,false),Var(y))), (None,Fld(FldFlags(false,false,false),Var(x)))))), App(Var(Baz),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))))))))),None,None,TypingUnit(List())))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))),None,None,List(App(Var(Bar),Tup(List((None,Fld(_,Var(y))), (None,Fld(_,Var(x)))))), App(Var(Baz),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))))))))),None,None,TypingUnit(List())))) //│ Lifted: //│ TypingUnit { //│ class Foo$1([x, y,]): Bar((this).y, (this).x,), Baz(+((this).x, (this).y,),) {} @@ -233,7 +233,7 @@ fun foo(x: T): string = //│ |#fun| |foo|‹|T|,| |U|›|(|x|#:| |T|)|#:| |string| |#=| |→|#class| |A|(|y|)| |#extends| |B|‹|T|›|,| |C|(|y|#:| |U|)| |{|→|#fun| |bar| |#=| |this|←|↵|}|↵|"rua"|←| //│ Parsed: {fun foo = (x: T,) => {class A(y,): B‹T›, C(y: U,) {fun bar = this}; "rua"} : string} //│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(TypeName(T), TypeName(U)),Left(Lam(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(T))))),Asc(Blk(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))),None,None,List(TyApp(Var(B),List(TypeName(T))), App(Var(C),Tup(List((Some(Var(y)),Fld(FldFlags(false,false,false),Var(U))))))),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(Var(this)))))), StrLit(rua))),TypeName(string))))))) +//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(TypeName(T), TypeName(U)),Left(Lam(Tup(List((Some(Var(x)),Fld(_,Var(T))))),Asc(Blk(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(_,Var(y)))))),None,None,List(TyApp(Var(B),List(TypeName(T))), App(Var(C),Tup(List((Some(Var(y)),Fld(_,Var(U))))))),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(Var(this)))))), StrLit(rua))),TypeName(string))))))) //│ Lifted: //│ TypingUnit { //│ class A$1[T,U]([y,]): B‹T›, C(y: U,) {fun bar = () => this} @@ -250,7 +250,7 @@ class A{ //│ |#class| |A|‹|T|›|{|→|#class| |B|{|→|#fun| |f| |#=| |x| |#=>| |y| |#=>| |x|↵|#fun| |g|#:| |T| |#=>| |B| |#=>| |T|←|↵|}|←|↵|}| //│ Parsed: {class A‹T› {class B {fun f = (x,) => (y,) => x; fun g: T -> B -> T}}} //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List((None,TypeName(T))),None,None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(y))))),Var(x))))), NuFunDef(None,Var(g),None,List(),Right(PolyType(List(),Function(Tuple(List((None,Field(None,TypeName(T))))),Function(Tuple(List((None,Field(None,TypeName(B))))),TypeName(T)))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List((None,TypeName(T))),None,None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Lam(Tup(List((None,Fld(_,Var(y))))),Var(x))))), NuFunDef(None,Var(g),None,List(),Right(PolyType(List(),Function(Tuple(List((None,Field(None,TypeName(T))))),Function(Tuple(List((None,Field(None,TypeName(B))))),TypeName(T)))))))))))))) //│ Lifted: //│ TypingUnit { //│ class A$1_B$2_Lambda1$1$3([par$A$1_B$2, x,]) {fun apply = (y,) => (this).x} @@ -293,7 +293,7 @@ fun ctx(a,b) = //│ |#class| |Func|‹|T|,| |U|›| |{|→|#fun| |apply|#:| |T| |#=>| |U|←|↵|}|↵|#class| |Lambda|‹|T|,| |U|›| |#:| |Func|‹|T|,| |U|›| |{||}|↵|#fun| |ctx|(|a|,|b|)| |#=|→|#fun| |foo|(|f|#:| |Func|,| |x|)| |#=| |→|f|.apply|(|x|)|←|↵|foo|(|#new| |Lambda|{|→|#fun| |apply|(|x|)| |#=| |a|+|x|←|↵|}|,| |b|)|←| //│ Parsed: {class Func‹T, U› {fun apply: T -> U}; class Lambda‹T, U›: Func[T, U] {}; fun ctx = (a, b,) => {fun foo = (f: Func, x,) => {(f).apply(x,)}; foo(new Lambda { ‹fun apply = (x,) => +(a, x,)› }, b,)}} //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Func),List((None,TypeName(T)), (None,TypeName(U))),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(apply),None,List(),Right(PolyType(List(),Function(Tuple(List((None,Field(None,TypeName(T))))),TypeName(U)))))))), NuTypeDef(Cls,TypeName(Lambda),List((None,TypeName(T)), (None,TypeName(U))),None,None,Some(AppliedType(TypeName(Func),List(TypeName(T), TypeName(U)))),List(),None,None,TypingUnit(List())), NuFunDef(None,Var(ctx),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),Var(b))))),Blk(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(f)),Fld(FldFlags(false,false,false),Var(Func))), (None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(App(Sel(Var(f),Var(apply)),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),Rft(NuNew(Var(Lambda)),TypingUnit(List(NuFunDef(None,Var(apply),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),Var(x)))))))))))))), (None,Fld(FldFlags(false,false,false),Var(b))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Func),List((None,TypeName(T)), (None,TypeName(U))),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(apply),None,List(),Right(PolyType(List(),Function(Tuple(List((None,Field(None,TypeName(T))))),TypeName(U)))))))), NuTypeDef(Cls,TypeName(Lambda),List((None,TypeName(T)), (None,TypeName(U))),None,None,Some(AppliedType(TypeName(Func),List(TypeName(T), TypeName(U)))),List(),None,None,TypingUnit(List())), NuFunDef(None,Var(ctx),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(a))), (None,Fld(_,Var(b))))),Blk(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(f)),Fld(_,Var(Func))), (None,Fld(_,Var(x))))),Blk(List(App(Sel(Var(f),Var(apply)),Tup(List((None,Fld(_,Var(x))))))))))), App(Var(foo),Tup(List((None,Fld(_,Rft(NuNew(Var(Lambda)),TypingUnit(List(NuFunDef(None,Var(apply),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(+),Tup(List((None,Fld(_,Var(a))), (None,Fld(_,Var(x)))))))))))))), (None,Fld(_,Var(b))))))))))))) //│ Lifted: //│ TypingUnit { //│ class Func$1[T,U]([]) {fun apply = T -> U} @@ -309,7 +309,7 @@ f(MyClass) //│ |#fun| |f|(|T|)| |#=| |→|#new| |T|(||)|←|↵|f|(|MyClass|)| //│ Parsed: {fun f = (T,) => {(new T)()}; f(MyClass,)} //│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(T))))),Blk(List(App(NuNew(Var(T)),Tup(List()))))))), App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),Var(MyClass)))))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(T))))),Blk(List(App(NuNew(Var(T)),Tup(List()))))))), App(Var(f),Tup(List((None,Fld(_,Var(MyClass)))))))) //│ Lifted: //│ Lifting failed: mlscript.codegen.CodeGenError: Cannot find type T. Class values are not supported in lifter. //│ diff --git a/compiler/shared/test/diff/mono.mls b/compiler/shared/test/diff/mono.mls index 43422ef6d..ef39b7e12 100644 --- a/compiler/shared/test/diff/mono.mls +++ b/compiler/shared/test/diff/mono.mls @@ -4,7 +4,7 @@ :mono fun f(x: Int) = if x then 42 else 1337 //│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(Int))))),If(IfThen(Var(x),IntLit(42)),Some(IntLit(1337)))))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(_,Var(Int))))),If(IfThen(Var(x),IntLit(42)),Some(IntLit(1337)))))))) //│ Lifted: //│ TypingUnit { //│ fun f$1 = (x: Int,) => if (x) then 42 else 1337 @@ -34,7 +34,7 @@ fun foo(x, #b) = if b then x else 1337 let a = foo(42, true) let b = foo(23, false) //│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,true,false),Var(b))))),If(IfThen(Var(b),Var(x)),Some(IntLit(1337)))))), NuFunDef(Some(false),Var(a),None,List(),Left(App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(42))), (None,Fld(FldFlags(false,false,false),Var(true)))))))), NuFunDef(Some(false),Var(b),None,List(),Left(App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(23))), (None,Fld(FldFlags(false,false,false),Var(false)))))))))) +//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))), (None,Fld(s,Var(b))))),If(IfThen(Var(b),Var(x)),Some(IntLit(1337)))))), NuFunDef(Some(false),Var(a),None,List(),Left(App(Var(foo),Tup(List((None,Fld(_,IntLit(42))), (None,Fld(_,Var(true)))))))), NuFunDef(Some(false),Var(b),None,List(),Left(App(Var(foo),Tup(List((None,Fld(_,IntLit(23))), (None,Fld(_,Var(false)))))))))) //│ Lifted: //│ TypingUnit { //│ fun foo$3 = (x, #b,) => if (b) then x else 1337 @@ -61,7 +61,7 @@ let b = foo(23, false) :mono let x = 42 + 1337 //│ Parsed: -//│ TypingUnit(List(NuFunDef(Some(false),Var(x),None,List(),Left(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(42))), (None,Fld(FldFlags(false,false,false),IntLit(1337)))))))))) +//│ TypingUnit(List(NuFunDef(Some(false),Var(x),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,IntLit(42))), (None,Fld(_,IntLit(1337)))))))))) //│ Lifted: //│ TypingUnit {let x$1 = () => +(42, 1337,)} //│ Mono: @@ -99,7 +99,7 @@ let x = 42 + 1337 if true then 1 else 0 if 1+1 > 1 then 1 - 1 else 1*1 //│ Parsed: -//│ TypingUnit(List(If(IfThen(Var(true),IntLit(1)),Some(IntLit(0))), If(IfThen(App(Var(>),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))),App(Var(-),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))),Some(App(Var(*),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))))))) +//│ TypingUnit(List(If(IfThen(Var(true),IntLit(1)),Some(IntLit(0))), If(IfThen(App(Var(>),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,IntLit(1)))))))), (None,Fld(_,IntLit(1)))))),App(Var(-),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,IntLit(1))))))),Some(App(Var(*),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,IntLit(1)))))))))) //│ Lifted: //│ TypingUnit { //│ Code(List(if (true) then 1 else 0)) @@ -139,7 +139,7 @@ if(b) then 1 else 2 :mono ((f, g) => f(g))(f => f, true) //│ Parsed: -//│ TypingUnit(List(App(Bra(false,Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(f))), (None,Fld(FldFlags(false,false,false),Var(g))))),App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),Var(g)))))))),Tup(List((None,Fld(FldFlags(false,false,false),Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(f))))),Var(f)))), (None,Fld(FldFlags(false,false,false),Var(true)))))))) +//│ TypingUnit(List(App(Bra(false,Lam(Tup(List((None,Fld(_,Var(f))), (None,Fld(_,Var(g))))),App(Var(f),Tup(List((None,Fld(_,Var(g)))))))),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(f))))),Var(f)))), (None,Fld(_,Var(true)))))))) //│ Lifted: //│ TypingUnit { //│ class Lambda2$1$1([]) {fun apply = (f, g,) => f(g,)} @@ -168,7 +168,7 @@ if(b) then 1 else 2 :mono (b => if b then true else false) (true) //│ Parsed: -//│ TypingUnit(List(App(Bra(false,Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(b))))),If(IfThen(Var(b),Var(true)),Some(Var(false))))),Tup(List((None,Fld(FldFlags(false,false,false),Var(true)))))))) +//│ TypingUnit(List(App(Bra(false,Lam(Tup(List((None,Fld(_,Var(b))))),If(IfThen(Var(b),Var(true)),Some(Var(false))))),Tup(List((None,Fld(_,Var(true)))))))) //│ Lifted: //│ TypingUnit { //│ class Lambda1$1$1([]) {fun apply = (b,) => if (b) then true else false} @@ -193,7 +193,7 @@ fun f(x) = if(x > 0) then x+1 else x - 1 f(2)+3 //│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(If(IfThen(Bra(false,App(Var(>),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(0))))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))),Some(App(Var(-),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))))))))), App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))))), (None,Fld(FldFlags(false,false,false),IntLit(3)))))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(If(IfThen(Bra(false,App(Var(>),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(0))))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1))))))),Some(App(Var(-),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1))))))))))))), App(Var(+),Tup(List((None,Fld(_,App(Var(f),Tup(List((None,Fld(_,IntLit(2)))))))), (None,Fld(_,IntLit(3)))))))) //│ Lifted: //│ TypingUnit { //│ fun f$1 = (x,) => {if ('(' >(x, 0,) ')') then +(x, 1,) else -(x, 1,)} @@ -217,7 +217,7 @@ fun fac(n) = if (n > 1) then fac(n - 1) * n else 1 fac(2) //│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(fac),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(n))))),Blk(List(If(IfThen(Bra(false,App(Var(>),Tup(List((None,Fld(FldFlags(false,false,false),Var(n))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))),App(Var(*),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(fac),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(-),Tup(List((None,Fld(FldFlags(false,false,false),Var(n))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))))))))), (None,Fld(FldFlags(false,false,false),Var(n))))))),Some(IntLit(1)))))))), App(Var(fac),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))))) +//│ TypingUnit(List(NuFunDef(None,Var(fac),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(n))))),Blk(List(If(IfThen(Bra(false,App(Var(>),Tup(List((None,Fld(_,Var(n))), (None,Fld(_,IntLit(1))))))),App(Var(*),Tup(List((None,Fld(_,App(Var(fac),Tup(List((None,Fld(_,App(Var(-),Tup(List((None,Fld(_,Var(n))), (None,Fld(_,IntLit(1))))))))))))), (None,Fld(_,Var(n))))))),Some(IntLit(1)))))))), App(Var(fac),Tup(List((None,Fld(_,IntLit(2)))))))) //│ Lifted: //│ TypingUnit { //│ fun fac$1 = (n,) => {if ('(' >(n, 1,) ')') then *(fac$1(-(n, 1,),), n,) else 1} @@ -246,7 +246,7 @@ fun count(lst) = else 0 count(new List(new List(new Nil(undefined, false), true), true)) //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(List),List(),Some(Tup(List((Some(Var(l)),Fld(FldFlags(false,false,true),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),Var(List))), (None,Fld(FldFlags(false,false,false),Var(Nil)))))))), (None,Fld(FldFlags(false,false,false),UnitLit(true)))))))), (Some(Var(hasTail)),Fld(FldFlags(false,false,true),Var(Bool)))))),None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List((Some(Var(l)),Fld(FldFlags(false,false,true),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),Var(List))), (None,Fld(FldFlags(false,false,false),Var(Nil)))))))), (None,Fld(FldFlags(false,false,false),UnitLit(true)))))))), (Some(Var(hasTail)),Fld(FldFlags(false,false,true),Var(Bool)))))),None,None,List(),None,None,TypingUnit(List())), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(lst))))),Blk(List(If(IfThen(Sel(Var(lst),Var(hasTail)),Blk(List(NuFunDef(Some(false),Var(l),None,List(),Left(Sel(Var(lst),Var(l)))), If(IfThen(App(Var(is),Tup(List((None,Fld(FldFlags(false,false,false),Var(l))), (None,Fld(FldFlags(false,false,false),UnitLit(true)))))),IntLit(1)),Some(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(count),Tup(List((None,Fld(FldFlags(false,false,false),Var(l)))))))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))))))),Some(IntLit(0)))))))), App(Var(count),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Nil)),Tup(List((None,Fld(FldFlags(false,false,false),UnitLit(true))), (None,Fld(FldFlags(false,false,false),Var(false)))))))), (None,Fld(FldFlags(false,false,false),Var(true)))))))), (None,Fld(FldFlags(false,false,false),Var(true))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(List),List(),Some(Tup(List((Some(Var(l)),Fld(g,App(Var(|),Tup(List((None,Fld(_,App(Var(|),Tup(List((None,Fld(_,Var(List))), (None,Fld(_,Var(Nil)))))))), (None,Fld(_,UnitLit(true)))))))), (Some(Var(hasTail)),Fld(g,Var(Bool)))))),None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List((Some(Var(l)),Fld(g,App(Var(|),Tup(List((None,Fld(_,App(Var(|),Tup(List((None,Fld(_,Var(List))), (None,Fld(_,Var(Nil)))))))), (None,Fld(_,UnitLit(true)))))))), (Some(Var(hasTail)),Fld(g,Var(Bool)))))),None,None,List(),None,None,TypingUnit(List())), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(lst))))),Blk(List(If(IfThen(Sel(Var(lst),Var(hasTail)),Blk(List(NuFunDef(Some(false),Var(l),None,List(),Left(Sel(Var(lst),Var(l)))), If(IfThen(App(Var(is),Tup(List((None,Fld(_,Var(l))), (None,Fld(_,UnitLit(true)))))),IntLit(1)),Some(App(Var(+),Tup(List((None,Fld(_,App(Var(count),Tup(List((None,Fld(_,Var(l)))))))), (None,Fld(_,IntLit(1))))))))))),Some(IntLit(0)))))))), App(Var(count),Tup(List((None,Fld(_,App(NuNew(Var(List)),Tup(List((None,Fld(_,App(NuNew(Var(List)),Tup(List((None,Fld(_,App(NuNew(Var(Nil)),Tup(List((None,Fld(_,UnitLit(true))), (None,Fld(_,Var(false)))))))), (None,Fld(_,Var(true)))))))), (None,Fld(_,Var(true))))))))))))) //│ Lifted: //│ TypingUnit { //│ class List$1([val l: |(|(List, Nil,), undefined,), val hasTail: Bool,]) {} @@ -303,7 +303,7 @@ class Nil() { fun add2(x) = x+2 (new List(1, new List(2, new Nil()))).map(x => x+1).map(x => add2(x)) //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(List),List(),Some(Tup(List((Some(Var(e)),Fld(FldFlags(false,false,false),Var(Int))), (Some(Var(tail)),Fld(FldFlags(false,false,false),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),Var(List))), (None,Fld(FldFlags(false,false,false),Var(Nil))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(map),None,List(),Right(PolyType(List(),Function(Tuple(List((None,Field(None,Function(Tuple(List((None,Field(None,TypeName(Int))))),TypeName(Int)))))),TypeName(List))))), NuFunDef(None,Var(map),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(f))))),App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),Var(e)))))))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(tail),Var(map)),Tup(List((None,Fld(FldFlags(false,false,false),Var(f)))))))))))))), NuFunDef(None,Var(count),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(tail),Var(count)),Tup(List()))))))))))))), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(map),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(f))))),Var(this)))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),IntLit(0))))))), NuFunDef(None,Var(add2),None,List(),Left(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(2))))))))), App(Sel(App(Sel(Bra(false,App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2))), (None,Fld(FldFlags(false,false,false),App(NuNew(Var(Nil)),Tup(List()))))))))))))),Var(map)),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)))))))))))),Var(map)),Tup(List((None,Fld(FldFlags(false,false,false),Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),App(Var(add2),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(List),List(),Some(Tup(List((Some(Var(e)),Fld(_,Var(Int))), (Some(Var(tail)),Fld(_,App(Var(|),Tup(List((None,Fld(_,Var(List))), (None,Fld(_,Var(Nil))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(map),None,List(),Right(PolyType(List(),Function(Tuple(List((None,Field(None,Function(Tuple(List((None,Field(None,TypeName(Int))))),TypeName(Int)))))),TypeName(List))))), NuFunDef(None,Var(map),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(f))))),App(NuNew(Var(List)),Tup(List((None,Fld(_,App(Var(f),Tup(List((None,Fld(_,Var(e)))))))), (None,Fld(_,App(Sel(Var(tail),Var(map)),Tup(List((None,Fld(_,Var(f)))))))))))))), NuFunDef(None,Var(count),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(Sel(Var(tail),Var(count)),Tup(List()))))))))))))), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(map),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(f))))),Var(this)))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),IntLit(0))))))), NuFunDef(None,Var(add2),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(2))))))))), App(Sel(App(Sel(Bra(false,App(NuNew(Var(List)),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(NuNew(Var(List)),Tup(List((None,Fld(_,IntLit(2))), (None,Fld(_,App(NuNew(Var(Nil)),Tup(List()))))))))))))),Var(map)),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1)))))))))))),Var(map)),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(add2),Tup(List((None,Fld(_,Var(x)))))))))))))) //│ Lifted: //│ TypingUnit { //│ class List$1([e: Int, tail: |(List, Nil,),]) { @@ -370,7 +370,7 @@ fun generate(x) = foo(new List(1, new List(2, new Nil()))) foo(generate(1)) //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(List),List(),Some(Tup(List((Some(Var(e)),Fld(FldFlags(false,false,false),Var(Int))), (Some(Var(tail)),Fld(FldFlags(false,false,false),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),Var(List))), (None,Fld(FldFlags(false,false,false),Var(Nil))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(tail),Var(count)),Tup(List()))))))))))))), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),IntLit(0))))))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),App(Sel(Var(x),Var(count)),Tup(List()))))), NuFunDef(None,Var(generate),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(If(IfThen(App(Var(>),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(0)))))),App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),App(Var(generate),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))))))))))))),Some(App(NuNew(Var(Nil)),Tup(List()))))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2))), (None,Fld(FldFlags(false,false,false),App(NuNew(Var(Nil)),Tup(List()))))))))))))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(generate),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(List),List(),Some(Tup(List((Some(Var(e)),Fld(_,Var(Int))), (Some(Var(tail)),Fld(_,App(Var(|),Tup(List((None,Fld(_,Var(List))), (None,Fld(_,Var(Nil))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(Sel(Var(tail),Var(count)),Tup(List()))))))))))))), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),IntLit(0))))))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),App(Sel(Var(x),Var(count)),Tup(List()))))), NuFunDef(None,Var(generate),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(If(IfThen(App(Var(>),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(0)))))),App(NuNew(Var(List)),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,App(Var(generate),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1))))))))))))))))),Some(App(NuNew(Var(Nil)),Tup(List()))))))))), App(Var(foo),Tup(List((None,Fld(_,App(NuNew(Var(List)),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(NuNew(Var(List)),Tup(List((None,Fld(_,IntLit(2))), (None,Fld(_,App(NuNew(Var(Nil)),Tup(List()))))))))))))))))), App(Var(foo),Tup(List((None,Fld(_,App(Var(generate),Tup(List((None,Fld(_,IntLit(1))))))))))))) //│ Lifted: //│ TypingUnit { //│ class List$1([e: Int, tail: |(List, Nil,),]) { @@ -424,7 +424,7 @@ fun foo(x) = (f => f(x))(z => z+1) foo(2) //│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(App(Bra(false,Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(f))))),App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))),Tup(List((None,Fld(FldFlags(false,false,false),Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(z))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(z))), (None,Fld(FldFlags(false,false,false),IntLit(1))))))))))))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))))) +//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(App(Bra(false,Lam(Tup(List((None,Fld(_,Var(f))))),App(Var(f),Tup(List((None,Fld(_,Var(x)))))))),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(z))))),App(Var(+),Tup(List((None,Fld(_,Var(z))), (None,Fld(_,IntLit(1))))))))))))))))), App(Var(foo),Tup(List((None,Fld(_,IntLit(2)))))))) //│ Lifted: //│ TypingUnit { //│ class Lambda1$2$1([x,]) {fun apply = (f,) => f((this).x,)} @@ -458,7 +458,7 @@ fun f(x) = (y => f(x+y))(x+1) f(1) //│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(App(Bra(false,Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(y))))),App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y))))))))))))),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))))))))))))), App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(App(Bra(false,Lam(Tup(List((None,Fld(_,Var(y))))),App(Var(f),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y))))))))))))),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1)))))))))))))))), App(Var(f),Tup(List((None,Fld(_,IntLit(1)))))))) //│ Lifted: //│ TypingUnit { //│ class Lambda1$2$1([x,]) {fun apply = (y,) => f$1(+((this).x, y,),)} @@ -489,7 +489,7 @@ fun f(x) = f(x) f(0) f(1) //│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))))))), App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))), App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))))) +//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(f),Tup(List((None,Fld(_,Var(x))))))))), App(Var(f),Tup(List((None,Fld(_,IntLit(0)))))), App(Var(f),Tup(List((None,Fld(_,IntLit(1)))))))) //│ Lifted: //│ TypingUnit { //│ fun f$1 = (x,) => f$1(x,) @@ -537,7 +537,7 @@ fun foo(x) = foo(new Lambda()) foo(new Lambda2(2)) //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Cons),List(),Some(Tup(List((Some(Var(e)),Fld(FldFlags(false,false,false),Var('A))), (Some(Var(tail)),Fld(FldFlags(false,false,false),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),Var(Cons))), (None,Fld(FldFlags(false,false,false),Var(Nil))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(tail),Var(count)),Tup(List()))))))))))))), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),IntLit(0))))))), NuTypeDef(Cls,TypeName(Lambda),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(apply),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(l))))),Blk(List(App(Sel(Var(l),Var(count)),Tup(List())))))))))), NuTypeDef(Cls,TypeName(Lambda2),List(),Some(Tup(List((Some(Var(a)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(apply),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(l))))),Blk(List(App(Sel(Bra(false,App(NuNew(Var(Cons)),Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),Var(l))))))),Var(count)),Tup(List())))))))))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Sel(Var(x),Var(apply)),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Cons)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(NuNew(Var(Nil)),Tup(List())))))))))))))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(x),Var(apply)),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Nil)),Tup(List()))))))))))))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Lambda)),Tup(List()))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Lambda2)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2))))))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Cons),List(),Some(Tup(List((Some(Var(e)),Fld(_,Var('A))), (Some(Var(tail)),Fld(_,App(Var(|),Tup(List((None,Fld(_,Var(Cons))), (None,Fld(_,Var(Nil))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(Sel(Var(tail),Var(count)),Tup(List()))))))))))))), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),IntLit(0))))))), NuTypeDef(Cls,TypeName(Lambda),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(apply),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(l))))),Blk(List(App(Sel(Var(l),Var(count)),Tup(List())))))))))), NuTypeDef(Cls,TypeName(Lambda2),List(),Some(Tup(List((Some(Var(a)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(apply),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(l))))),Blk(List(App(Sel(Bra(false,App(NuNew(Var(Cons)),Tup(List((None,Fld(_,Var(a))), (None,Fld(_,Var(l))))))),Var(count)),Tup(List())))))))))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(App(Var(+),Tup(List((None,Fld(_,App(Sel(Var(x),Var(apply)),Tup(List((None,Fld(_,App(NuNew(Var(Cons)),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(NuNew(Var(Nil)),Tup(List())))))))))))))), (None,Fld(_,App(Sel(Var(x),Var(apply)),Tup(List((None,Fld(_,App(NuNew(Var(Nil)),Tup(List()))))))))))))))))), App(Var(foo),Tup(List((None,Fld(_,App(NuNew(Var(Lambda)),Tup(List()))))))), App(Var(foo),Tup(List((None,Fld(_,App(NuNew(Var(Lambda2)),Tup(List((None,Fld(_,IntLit(2))))))))))))) //│ Lifted: //│ TypingUnit { //│ class Cons$1([e: 'A, tail: |(Cons, Nil,),]) { @@ -612,7 +612,7 @@ fun foo(x) = foo(l => l.count()) foo(l => (new Cons(2, l)).count()) //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Cons),List(),Some(Tup(List((Some(Var(e)),Fld(FldFlags(false,false,false),Var(Int))), (Some(Var(tail)),Fld(FldFlags(false,false,false),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),Var(Cons))), (None,Fld(FldFlags(false,false,false),Var(Nil))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(tail),Var(count)),Tup(List()))))))))))))), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),IntLit(0))))))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(x),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Cons)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(NuNew(Var(Nil)),Tup(List())))))))))))))), (None,Fld(FldFlags(false,false,false),App(Var(x),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Nil)),Tup(List()))))))))))))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(l))))),App(Sel(Var(l),Var(count)),Tup(List())))))))), App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(l))))),App(Sel(Bra(false,App(NuNew(Var(Cons)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2))), (None,Fld(FldFlags(false,false,false),Var(l))))))),Var(count)),Tup(List())))))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Cons),List(),Some(Tup(List((Some(Var(e)),Fld(_,Var(Int))), (Some(Var(tail)),Fld(_,App(Var(|),Tup(List((None,Fld(_,Var(Cons))), (None,Fld(_,Var(Nil))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(Sel(Var(tail),Var(count)),Tup(List()))))))))))))), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),IntLit(0))))))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(App(Var(+),Tup(List((None,Fld(_,App(Var(x),Tup(List((None,Fld(_,App(NuNew(Var(Cons)),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(NuNew(Var(Nil)),Tup(List())))))))))))))), (None,Fld(_,App(Var(x),Tup(List((None,Fld(_,App(NuNew(Var(Nil)),Tup(List()))))))))))))))))), App(Var(foo),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(l))))),App(Sel(Var(l),Var(count)),Tup(List())))))))), App(Var(foo),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(l))))),App(Sel(Bra(false,App(NuNew(Var(Cons)),Tup(List((None,Fld(_,IntLit(2))), (None,Fld(_,Var(l))))))),Var(count)),Tup(List())))))))))) //│ Lifted: //│ TypingUnit { //│ class Cons$1([e: Int, tail: |(Cons, Nil,),]) { @@ -707,7 +707,7 @@ class C(e1: Exp, e2: Exp) extends Exp { } (new C(new Ch(1), new A(new Ch(2), new Ch(3)))).derive(0).isEmpty() //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Exp),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Right(PolyType(List(),Function(Tuple(List((Some(Var(x)),Field(None,TypeName(Int))))),TypeName(Exp))))), NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(Int))))),App(Var(Exp),Tup(List()))))), NuFunDef(None,Var(isEmpty),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Bool))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Var(false))))))), NuTypeDef(Cls,TypeName(E),List(),Some(Tup(List())),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(NuNew(Var(E))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(Var(false))))))))), NuTypeDef(Cls,TypeName(Ep),List(),Some(Tup(List())),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(NuNew(Var(E))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(Var(true))))))))), NuTypeDef(Cls,TypeName(Ch),List(),Some(Tup(List((Some(Var(i)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(If(IfThen(App(Var(==),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(i)))))),NuNew(Var(Ep))),Some(NuNew(Var(E))))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(Var(false))))))))), NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((Some(Var(e1)),Fld(FldFlags(false,false,false),Var(Exp))), (Some(Var(e2)),Fld(FldFlags(false,false,false),Var(Exp)))))),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(App(NuNew(Var(A)),Tup(List((None,Fld(FldFlags(false,false,false),App(Sel(Var(e1),Var(derive)),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(e2),Var(derive)),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))))))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(App(Var(||),Tup(List((None,Fld(FldFlags(false,false,false),App(Sel(Var(e1),Var(isEmpty)),Tup(List())))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(e2),Var(isEmpty)),Tup(List()))))))))))))))), NuTypeDef(Cls,TypeName(C),List(),Some(Tup(List((Some(Var(e1)),Fld(FldFlags(false,false,false),Var(Exp))), (Some(Var(e2)),Fld(FldFlags(false,false,false),Var(Exp)))))),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(If(IfThen(App(Sel(Var(e1),Var(isEmpty)),Tup(List())),App(NuNew(Var(A)),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(C)),Tup(List((None,Fld(FldFlags(false,false,false),App(Sel(Var(e1),Var(derive)),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))), (None,Fld(FldFlags(false,false,false),Var(e2)))))))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(e2),Var(derive)),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))))))),Some(App(NuNew(Var(C)),Tup(List((None,Fld(FldFlags(false,false,false),App(Sel(Var(e1),Var(derive)),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))))), (None,Fld(FldFlags(false,false,false),Var(e2))))))))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(App(Var(&&),Tup(List((None,Fld(FldFlags(false,false,false),App(Sel(Var(e1),Var(isEmpty)),Tup(List())))), (None,Fld(FldFlags(false,false,false),App(Sel(Var(e2),Var(isEmpty)),Tup(List()))))))))))))))), App(Sel(App(Sel(Bra(false,App(NuNew(Var(C)),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Ch)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))))), (None,Fld(FldFlags(false,false,false),App(NuNew(Var(A)),Tup(List((None,Fld(FldFlags(false,false,false),App(NuNew(Var(Ch)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))))), (None,Fld(FldFlags(false,false,false),App(NuNew(Var(Ch)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(3))))))))))))))))),Var(derive)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))),Var(isEmpty)),Tup(List())))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Exp),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Right(PolyType(List(),Function(Tuple(List((Some(Var(x)),Field(None,TypeName(Int))))),TypeName(Exp))))), NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(_,Var(Int))))),App(Var(Exp),Tup(List()))))), NuFunDef(None,Var(isEmpty),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Bool))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Var(false))))))), NuTypeDef(Cls,TypeName(E),List(),Some(Tup(List())),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(NuNew(Var(E))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(Var(false))))))))), NuTypeDef(Cls,TypeName(Ep),List(),Some(Tup(List())),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(NuNew(Var(E))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(Var(true))))))))), NuTypeDef(Cls,TypeName(Ch),List(),Some(Tup(List((Some(Var(i)),Fld(_,Var(Int)))))),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(If(IfThen(App(Var(==),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(i)))))),NuNew(Var(Ep))),Some(NuNew(Var(E))))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(Var(false))))))))), NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((Some(Var(e1)),Fld(_,Var(Exp))), (Some(Var(e2)),Fld(_,Var(Exp)))))),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(App(NuNew(Var(A)),Tup(List((None,Fld(_,App(Sel(Var(e1),Var(derive)),Tup(List((None,Fld(_,Var(x)))))))), (None,Fld(_,App(Sel(Var(e2),Var(derive)),Tup(List((None,Fld(_,Var(x)))))))))))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(App(Var(||),Tup(List((None,Fld(_,App(Sel(Var(e1),Var(isEmpty)),Tup(List())))), (None,Fld(_,App(Sel(Var(e2),Var(isEmpty)),Tup(List()))))))))))))))), NuTypeDef(Cls,TypeName(C),List(),Some(Tup(List((Some(Var(e1)),Fld(_,Var(Exp))), (Some(Var(e2)),Fld(_,Var(Exp)))))),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(If(IfThen(App(Sel(Var(e1),Var(isEmpty)),Tup(List())),App(NuNew(Var(A)),Tup(List((None,Fld(_,App(NuNew(Var(C)),Tup(List((None,Fld(_,App(Sel(Var(e1),Var(derive)),Tup(List((None,Fld(_,Var(x)))))))), (None,Fld(_,Var(e2)))))))), (None,Fld(_,App(Sel(Var(e2),Var(derive)),Tup(List((None,Fld(_,Var(x)))))))))))),Some(App(NuNew(Var(C)),Tup(List((None,Fld(_,App(Sel(Var(e1),Var(derive)),Tup(List((None,Fld(_,Var(x)))))))), (None,Fld(_,Var(e2))))))))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(App(Var(&&),Tup(List((None,Fld(_,App(Sel(Var(e1),Var(isEmpty)),Tup(List())))), (None,Fld(_,App(Sel(Var(e2),Var(isEmpty)),Tup(List()))))))))))))))), App(Sel(App(Sel(Bra(false,App(NuNew(Var(C)),Tup(List((None,Fld(_,App(NuNew(Var(Ch)),Tup(List((None,Fld(_,IntLit(1)))))))), (None,Fld(_,App(NuNew(Var(A)),Tup(List((None,Fld(_,App(NuNew(Var(Ch)),Tup(List((None,Fld(_,IntLit(2)))))))), (None,Fld(_,App(NuNew(Var(Ch)),Tup(List((None,Fld(_,IntLit(3))))))))))))))))),Var(derive)),Tup(List((None,Fld(_,IntLit(0)))))),Var(isEmpty)),Tup(List())))) //│ Lifted: //│ TypingUnit { //│ class Exp$1([]) { @@ -809,7 +809,7 @@ fun gen() = if anyUnknown then new List(gen(), true) else new Nil(false) gen() //│ Parsed: -//│ TypingUnit(List(NuFunDef(Some(false),Var(anyUnknown),None,List(),Left(Var(false))), NuTypeDef(Cls,TypeName(List),List(),Some(Tup(List((Some(Var(l)),Fld(FldFlags(false,false,false),App(Var(|),Tup(List((None,Fld(FldFlags(false,false,false),Var(List))), (None,Fld(FldFlags(false,false,false),Var(Nil)))))))), (Some(Var(hasTail)),Fld(FldFlags(false,false,false),Var(Bool)))))),None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List((Some(Var(hasTail)),Fld(FldFlags(false,false,false),Var(Bool)))))),None,None,List(),None,None,TypingUnit(List())), NuFunDef(None,Var(gen),None,List(),Left(Lam(Tup(List()),Blk(List(If(IfThen(Var(anyUnknown),App(NuNew(Var(List)),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(gen),Tup(List())))), (None,Fld(FldFlags(false,false,false),Var(true))))))),Some(App(NuNew(Var(Nil)),Tup(List((None,Fld(FldFlags(false,false,false),Var(false))))))))))))), App(Var(gen),Tup(List())))) +//│ TypingUnit(List(NuFunDef(Some(false),Var(anyUnknown),None,List(),Left(Var(false))), NuTypeDef(Cls,TypeName(List),List(),Some(Tup(List((Some(Var(l)),Fld(_,App(Var(|),Tup(List((None,Fld(_,Var(List))), (None,Fld(_,Var(Nil)))))))), (Some(Var(hasTail)),Fld(_,Var(Bool)))))),None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List((Some(Var(hasTail)),Fld(_,Var(Bool)))))),None,None,List(),None,None,TypingUnit(List())), NuFunDef(None,Var(gen),None,List(),Left(Lam(Tup(List()),Blk(List(If(IfThen(Var(anyUnknown),App(NuNew(Var(List)),Tup(List((None,Fld(_,App(Var(gen),Tup(List())))), (None,Fld(_,Var(true))))))),Some(App(NuNew(Var(Nil)),Tup(List((None,Fld(_,Var(false))))))))))))), App(Var(gen),Tup(List())))) //│ Lifted: //│ TypingUnit { //│ class List$1([l: |(List, Nil,), hasTail: Bool,]) {} @@ -851,7 +851,7 @@ class Foo(x: Int){ } (new Foo(1)).boo(2) //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((Some(Var(x)),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(y))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y))))))))), NuFunDef(None,Var(boo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(z))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(bar),Tup(List((None,Fld(FldFlags(false,false,false),Var(z)))))))), (None,Fld(FldFlags(false,false,false),Var(x)))))))))))), App(Sel(Bra(false,App(NuNew(Var(Foo)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))))))),Var(boo)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((Some(Var(x)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(y))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y))))))))), NuFunDef(None,Var(boo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(z))))),App(Var(+),Tup(List((None,Fld(_,App(Var(bar),Tup(List((None,Fld(_,Var(z)))))))), (None,Fld(_,Var(x)))))))))))), App(Sel(Bra(false,App(NuNew(Var(Foo)),Tup(List((None,Fld(_,IntLit(1))))))),Var(boo)),Tup(List((None,Fld(_,IntLit(2)))))))) //│ Lifted: //│ TypingUnit { //│ class Foo$1([x: Int,]) { @@ -888,7 +888,7 @@ class OneInt(a: Int){ } (new OneInt(10)).fac() //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(OneInt),List(),Some(Tup(List((Some(Var(a)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(fac),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(fac),None,List(),Left(Lam(Tup(List()),Blk(List(If(IfThen(Bra(false,App(Var(>),Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),IntLit(0))))))),App(Sel(Bra(false,App(NuNew(Var(OneInt)),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(-),Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))))))))),Var(fac)),Tup(List()))),Some(IntLit(1))))))))))), App(Sel(Bra(false,App(NuNew(Var(OneInt)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(10))))))),Var(fac)),Tup(List())))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(OneInt),List(),Some(Tup(List((Some(Var(a)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(fac),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(fac),None,List(),Left(Lam(Tup(List()),Blk(List(If(IfThen(Bra(false,App(Var(>),Tup(List((None,Fld(_,Var(a))), (None,Fld(_,IntLit(0))))))),App(Sel(Bra(false,App(NuNew(Var(OneInt)),Tup(List((None,Fld(_,App(Var(-),Tup(List((None,Fld(_,Var(a))), (None,Fld(_,IntLit(1)))))))))))),Var(fac)),Tup(List()))),Some(IntLit(1))))))))))), App(Sel(Bra(false,App(NuNew(Var(OneInt)),Tup(List((None,Fld(_,IntLit(10))))))),Var(fac)),Tup(List())))) //│ Lifted: //│ TypingUnit { //│ class OneInt$1([a: Int,]) { @@ -938,7 +938,7 @@ fun g(x) = else f(x - 2) g(1) //│ Parsed: -//│ TypingUnit(List(NuFunDef(Some(false),Var(any),None,List(),Left(IntLit(-20))), NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(If(IfThen(App(Var(>),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(any)))))),IntLit(0)),Some(App(Var(g),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(-),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))))))))))))))), NuFunDef(None,Var(g),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Blk(List(If(IfThen(App(Var(>),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(any)))))),App(Var(g),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(-),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(1)))))))))))),Some(App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(-),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),IntLit(2)))))))))))))))))), App(Var(g),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))))) +//│ TypingUnit(List(NuFunDef(Some(false),Var(any),None,List(),Left(IntLit(-20))), NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(If(IfThen(App(Var(>),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(any)))))),IntLit(0)),Some(App(Var(g),Tup(List((None,Fld(_,App(Var(-),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1)))))))))))))))))), NuFunDef(None,Var(g),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(If(IfThen(App(Var(>),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(any)))))),App(Var(g),Tup(List((None,Fld(_,App(Var(-),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1)))))))))))),Some(App(Var(f),Tup(List((None,Fld(_,App(Var(-),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(2)))))))))))))))))), App(Var(g),Tup(List((None,Fld(_,IntLit(1)))))))) //│ Lifted: //│ TypingUnit { //│ let any$3 = () => -20 @@ -977,7 +977,7 @@ class OneBool(b: Bool){ } (if b then new OneInt(1) else new OneBool(true)).get() //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(OneInt),List(),Some(Tup(List((Some(Var(a)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(get),None,List(),Left(Lam(Tup(List()),Var(a))))))), NuTypeDef(Cls,TypeName(OneBool),List(),Some(Tup(List((Some(Var(b)),Fld(FldFlags(false,false,false),Var(Bool)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(get),None,List(),Left(Lam(Tup(List()),Var(b))))))), App(Sel(Bra(false,If(IfThen(Var(b),App(NuNew(Var(OneInt)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))))))),Some(App(NuNew(Var(OneBool)),Tup(List((None,Fld(FldFlags(false,false,false),Var(true))))))))),Var(get)),Tup(List())))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(OneInt),List(),Some(Tup(List((Some(Var(a)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(get),None,List(),Left(Lam(Tup(List()),Var(a))))))), NuTypeDef(Cls,TypeName(OneBool),List(),Some(Tup(List((Some(Var(b)),Fld(_,Var(Bool)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(get),None,List(),Left(Lam(Tup(List()),Var(b))))))), App(Sel(Bra(false,If(IfThen(Var(b),App(NuNew(Var(OneInt)),Tup(List((None,Fld(_,IntLit(1))))))),Some(App(NuNew(Var(OneBool)),Tup(List((None,Fld(_,Var(true))))))))),Var(get)),Tup(List())))) //│ Lifted: //│ TypingUnit { //│ class OneInt$1([a: Int,]) {fun get = () => (this).a} @@ -1023,7 +1023,7 @@ baz(bar) (new Car()).da(Bar(1337)) bar.car //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Bar),List(),Some(Tup(List((Some(Var(x)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))))),Var(x)))), NuFunDef(None,Var(FooMinus),None,List(),Left(Lam(Tup(List((Some(Var(y)),Fld(FldFlags(false,false,false),Var(Int))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y))))))))), NuFunDef(None,Var(car),None,List(),Left(App(Var(foo),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2))))))))))), NuTypeDef(Cls,TypeName(Car),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(da),None,List(),Left(Lam(Tup(List((Some(Var(b)),Fld(FldFlags(false,false,false),Var(Bar))))),App(Sel(Var(b),Var(foo)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))))))))), NuFunDef(None,Var(baz),None,List(),Left(Lam(Tup(List((Some(Var(b)),Fld(FldFlags(false,false,false),Var(Bar))))),App(Sel(Var(b),Var(foo)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2))))))))), NuFunDef(Some(false),Var(bar),None,List(),Left(App(Var(Bar),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(42)))))))), App(Var(baz),Tup(List((None,Fld(FldFlags(false,false,false),Var(bar)))))), App(Sel(Bra(false,App(NuNew(Var(Car)),Tup(List()))),Var(da)),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(Bar),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1337))))))))))), Sel(Var(bar),Var(car)))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Bar),List(),Some(Tup(List((Some(Var(x)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Var(x)))), NuFunDef(None,Var(FooMinus),None,List(),Left(Lam(Tup(List((Some(Var(y)),Fld(_,Var(Int))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y))))))))), NuFunDef(None,Var(car),None,List(),Left(App(Var(foo),Tup(List((None,Fld(_,IntLit(2))))))))))), NuTypeDef(Cls,TypeName(Car),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(da),None,List(),Left(Lam(Tup(List((Some(Var(b)),Fld(_,Var(Bar))))),App(Sel(Var(b),Var(foo)),Tup(List((None,Fld(_,IntLit(2)))))))))))), NuFunDef(None,Var(baz),None,List(),Left(Lam(Tup(List((Some(Var(b)),Fld(_,Var(Bar))))),App(Sel(Var(b),Var(foo)),Tup(List((None,Fld(_,IntLit(2))))))))), NuFunDef(Some(false),Var(bar),None,List(),Left(App(Var(Bar),Tup(List((None,Fld(_,IntLit(42)))))))), App(Var(baz),Tup(List((None,Fld(_,Var(bar)))))), App(Sel(Bra(false,App(NuNew(Var(Car)),Tup(List()))),Var(da)),Tup(List((None,Fld(_,App(Var(Bar),Tup(List((None,Fld(_,IntLit(1337))))))))))), Sel(Var(bar),Var(car)))) //│ Lifted: //│ TypingUnit { //│ class Bar$1([x: Int,]) { @@ -1094,7 +1094,7 @@ class Sub2(c: Int) extends Sub(c+c){ (new Sub(10)).foo() (new Sub2(c)).foo() //│ Parsed: -//│ TypingUnit(List(NuFunDef(Some(false),Var(c),None,List(),Left(IntLit(5))), NuTypeDef(Cls,TypeName(Sup),List(),Some(Tup(List((Some(Var(a)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List()),Var(a))))))), NuTypeDef(Cls,TypeName(Sub),List(),Some(Tup(List((Some(Var(b)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(App(Var(Sup),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(b))), (None,Fld(FldFlags(false,false,false),Var(b)))))))))))),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(Sub2),List(),Some(Tup(List((Some(Var(c)),Fld(FldFlags(false,false,false),Var(Int)))))),None,None,List(App(Var(Sub),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(c))), (None,Fld(FldFlags(false,false,false),Var(c)))))))))))),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),Var(c)))))))))))), App(Sel(Bra(false,App(NuNew(Var(Sub)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(10))))))),Var(foo)),Tup(List())), App(Sel(Bra(false,App(NuNew(Var(Sub2)),Tup(List((None,Fld(FldFlags(false,false,false),Var(c))))))),Var(foo)),Tup(List())))) +//│ TypingUnit(List(NuFunDef(Some(false),Var(c),None,List(),Left(IntLit(5))), NuTypeDef(Cls,TypeName(Sup),List(),Some(Tup(List((Some(Var(a)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List()),Var(a))))))), NuTypeDef(Cls,TypeName(Sub),List(),Some(Tup(List((Some(Var(b)),Fld(_,Var(Int)))))),None,None,List(App(Var(Sup),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(b))), (None,Fld(_,Var(b)))))))))))),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(Sub2),List(),Some(Tup(List((Some(Var(c)),Fld(_,Var(Int)))))),None,None,List(App(Var(Sub),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(c))), (None,Fld(_,Var(c)))))))))))),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(_,Var(a))), (None,Fld(_,Var(c)))))))))))), App(Sel(Bra(false,App(NuNew(Var(Sub)),Tup(List((None,Fld(_,IntLit(10))))))),Var(foo)),Tup(List())), App(Sel(Bra(false,App(NuNew(Var(Sub2)),Tup(List((None,Fld(_,Var(c))))))),Var(foo)),Tup(List())))) //│ Lifted: //│ TypingUnit { //│ class Sup$1([a: Int,]) {fun foo = () => (this).a} @@ -1152,7 +1152,7 @@ class F2() extends Foo(x => x+2){} (new F1()).foo() (new F2()).foo() //│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((Some(Var(f)),Fld(FldFlags(false,false,false),App(Var(->),Tup(List((None,Fld(FldFlags(false,false,false),Var(Int))), (None,Fld(FldFlags(false,false,false),Var(Int))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List()),App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))))))))), NuTypeDef(Cls,TypeName(F1),List(),Some(Tup(List())),None,None,List(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))))))))))))),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(F2),List(),Some(Tup(List())),None,None,List(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(2))))))))))))),None,None,TypingUnit(List())), App(Sel(Bra(false,App(NuNew(Var(F1)),Tup(List()))),Var(foo)),Tup(List())), App(Sel(Bra(false,App(NuNew(Var(F2)),Tup(List()))),Var(foo)),Tup(List())))) +//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((Some(Var(f)),Fld(_,App(Var(->),Tup(List((None,Fld(_,Var(Int))), (None,Fld(_,Var(Int))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List()),App(Var(f),Tup(List((None,Fld(_,IntLit(1)))))))))))), NuTypeDef(Cls,TypeName(F1),List(),Some(Tup(List())),None,None,List(App(Var(Foo),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1))))))))))))),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(F2),List(),Some(Tup(List())),None,None,List(App(Var(Foo),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(2))))))))))))),None,None,TypingUnit(List())), App(Sel(Bra(false,App(NuNew(Var(F1)),Tup(List()))),Var(foo)),Tup(List())), App(Sel(Bra(false,App(NuNew(Var(F2)),Tup(List()))),Var(foo)),Tup(List())))) //│ Lifted: //│ TypingUnit { //│ class Foo$1([f: ->(Int, Int,),]) {fun foo = () => (this).f(1,)} diff --git a/shared/src/main/scala/mlscript/helpers.scala b/shared/src/main/scala/mlscript/helpers.scala index 63de7f026..57b2a5aea 100644 --- a/shared/src/main/scala/mlscript/helpers.scala +++ b/shared/src/main/scala/mlscript/helpers.scala @@ -504,6 +504,15 @@ trait TypeNameImpl extends Ordered[TypeName] { self: TypeName => lazy val toVar: Var = Var(name).withLocOf(this) } +trait FldFlagsImpl extends Located { self: FldFlags => + def children: Ls[Located] = Nil + override def toString(): String = { + val FldFlags(m, s, g) = this + val res = (if (m) "m" else "") + (if (s) "s" else "") + (if (g) "g" else "") + if (res.isEmpty) "_" else res + } +} + trait FldImpl extends Located { self: Fld => def children: Ls[Located] = self.value :: Nil def describe: Str = diff --git a/shared/src/main/scala/mlscript/syntax.scala b/shared/src/main/scala/mlscript/syntax.scala index e899ff582..d3d3b05c4 100644 --- a/shared/src/main/scala/mlscript/syntax.scala +++ b/shared/src/main/scala/mlscript/syntax.scala @@ -104,7 +104,7 @@ final case class IfOpsApp(lhs: Term, opsRhss: Ls[Var -> IfBody]) extends IfBody final case class IfBlock(lines: Ls[IfBody \/ Statement]) extends IfBody // final case class IfApp(fun: Term, opsRhss: Ls[Var -> IfBody]) extends IfBody -final case class FldFlags(mut: Bool, spec: Bool, genGetter: Bool) +final case class FldFlags(mut: Bool, spec: Bool, genGetter: Bool) extends FldFlagsImpl final case class Fld(flags: FldFlags, value: Term) extends FldImpl object FldFlags { val empty: FldFlags = FldFlags(false, false, false) } diff --git a/shared/src/test/diff/mlscript/Basics.mls b/shared/src/test/diff/mlscript/Basics.mls index b93076134..7ecdfea0f 100644 --- a/shared/src/test/diff/mlscript/Basics.mls +++ b/shared/src/test/diff/mlscript/Basics.mls @@ -96,7 +96,7 @@ def f (x y z) = add x y //│ ╙── ^^^^^ //│ f: error -> int //│ Code generation encountered an error: -//│ term App(App(Var(x),Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))),Tup(List((None,Fld(FldFlags(false,false,false),Var(z)))))) is not a valid pattern +//│ term App(App(Var(x),Tup(List((None,Fld(_,Var(y)))))),Tup(List((None,Fld(_,Var(z)))))) is not a valid pattern f 1 //│ res: int diff --git a/shared/src/test/diff/mlscript/ByNameByValue.mls b/shared/src/test/diff/mlscript/ByNameByValue.mls index ddef8f3d9..a9b9b9b18 100644 --- a/shared/src/test/diff/mlscript/ByNameByValue.mls +++ b/shared/src/test/diff/mlscript/ByNameByValue.mls @@ -16,7 +16,7 @@ def incr x = x.a <- x.a + 1 def gensym = let n = { mut a = 0 } in fun () -> (incr n, n) //│ Parsed: def gensym: let n = {mut a: 0} in () => [incr(n,), n,]; //│ Desugared: def gensym: let n = {mut a: 0} in () => [incr(n,), n,] -//│ AST: Def(false,Var(gensym),Left(Let(false,Var(n),Rcd(List((Var(a),Fld(FldFlags(true,false,false),IntLit(0))))),Lam(Tup(List()),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(incr),Tup(List((None,Fld(FldFlags(false,false,false),Var(n)))))))), (None,Fld(FldFlags(false,false,false),Var(n)))))))),true) +//│ AST: Def(false,Var(gensym),Left(Let(false,Var(n),Rcd(List((Var(a),Fld(m,IntLit(0))))),Lam(Tup(List()),Tup(List((None,Fld(_,App(Var(incr),Tup(List((None,Fld(_,Var(n)))))))), (None,Fld(_,Var(n)))))))),true) //│ // Query 1 //│ globalThis.gensym = function gensym() { //│ return (((n) => () => [ @@ -35,7 +35,7 @@ def gensym = let n = { mut a = 0 } in fun () -> (incr n, n) gensym1 = let n = { mut a = 0 } in fun () -> (incr n, n) //│ Parsed: let gensym1 = let n = {mut a: 0} in () => [incr(n,), n,]; //│ Desugared: def gensym1: let n = {mut a: 0} in () => [incr(n,), n,] -//│ AST: Def(false,Var(gensym1),Left(Let(false,Var(n),Rcd(List((Var(a),Fld(FldFlags(true,false,false),IntLit(0))))),Lam(Tup(List()),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(incr),Tup(List((None,Fld(FldFlags(false,false,false),Var(n)))))))), (None,Fld(FldFlags(false,false,false),Var(n)))))))),false) +//│ AST: Def(false,Var(gensym1),Left(Let(false,Var(n),Rcd(List((Var(a),Fld(m,IntLit(0))))),Lam(Tup(List()),Tup(List((None,Fld(_,App(Var(incr),Tup(List((None,Fld(_,Var(n)))))))), (None,Fld(_,Var(n)))))))),false) //│ // Query 1 //│ globalThis.gensym1 = ((n) => () => [ //│ incr(n), diff --git a/shared/src/test/diff/mlscript/MultiArgs.mls b/shared/src/test/diff/mlscript/MultiArgs.mls index 996bc44af..9f04e7f15 100644 --- a/shared/src/test/diff/mlscript/MultiArgs.mls +++ b/shared/src/test/diff/mlscript/MultiArgs.mls @@ -75,9 +75,9 @@ f = fun (x, y) -> add x y f(1, 2) //│ Parsed: let f = (x, y,) => add(x,)(y,); f(1, 2,); //│ Desugared: def f: (x, y,) => add(x,)(y,) -//│ AST: Def(false,Var(f),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y))))),App(App(Var(add),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))))),false) +//│ AST: Def(false,Var(f),Left(Lam(Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y))))),App(App(Var(add),Tup(List((None,Fld(_,Var(x)))))),Tup(List((None,Fld(_,Var(y)))))))),false) //│ Desugared: f(1, 2,) -//│ AST: App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),IntLit(2)))))) +//│ AST: App(Var(f),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,IntLit(2)))))) //│ f: (int, int,) -> int //│ = [Function: f] //│ res: int @@ -119,9 +119,9 @@ f = fun ((x, y)) -> add x y f((1, 2)) //│ Parsed: let f = ('(' [x, y,] ')',) => add(x,)(y,); f('(' [1, 2,] ')',); //│ Desugared: def f: ('(' [x, y,] ')',) => add(x,)(y,) -//│ AST: Def(false,Var(f),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Bra(false,Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))))))),App(App(Var(add),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))),Tup(List((None,Fld(FldFlags(false,false,false),Var(y)))))))),false) +//│ AST: Def(false,Var(f),Left(Lam(Tup(List((None,Fld(_,Bra(false,Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))))))),App(App(Var(add),Tup(List((None,Fld(_,Var(x)))))),Tup(List((None,Fld(_,Var(y)))))))),false) //│ Desugared: f('(' [1, 2,] ')',) -//│ AST: App(Var(f),Tup(List((None,Fld(FldFlags(false,false,false),Bra(false,Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),IntLit(2))))))))))) +//│ AST: App(Var(f),Tup(List((None,Fld(_,Bra(false,Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,IntLit(2))))))))))) //│ f: ((int, int,),) -> int //│ = [Function: f1] //│ res: int diff --git a/shared/src/test/diff/mlscript/Ops.mls b/shared/src/test/diff/mlscript/Ops.mls index 6dbb47205..fb99294cf 100644 --- a/shared/src/test/diff/mlscript/Ops.mls +++ b/shared/src/test/diff/mlscript/Ops.mls @@ -3,7 +3,7 @@ 2 + 2 //│ Parsed: +(2,)(2,); //│ Desugared: +(2,)(2,) -//│ AST: App(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))) +//│ AST: App(App(Var(+),Tup(List((None,Fld(_,IntLit(2)))))),Tup(List((None,Fld(_,IntLit(2)))))) //│ res: int //│ = 4 @@ -11,7 +11,7 @@ 1 + 2 * 2 + 3 //│ Parsed: +(+(1,)(*(2,)(2,),),)(3,); //│ Desugared: +(+(1,)(*(2,)(2,),),)(3,) -//│ AST: App(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(*),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))))))))))))),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(3)))))) +//│ AST: App(App(Var(+),Tup(List((None,Fld(_,App(App(Var(+),Tup(List((None,Fld(_,IntLit(1)))))),Tup(List((None,Fld(_,App(App(Var(*),Tup(List((None,Fld(_,IntLit(2)))))),Tup(List((None,Fld(_,IntLit(2)))))))))))))))),Tup(List((None,Fld(_,IntLit(3)))))) //│ res: int //│ = 8 @@ -20,7 +20,7 @@ 1 + 2 / 2 + 3 //│ Parsed: +(+(1,)(/(2,)(2,),),)(3,); //│ Desugared: +(+(1,)(/(2,)(2,),),)(3,) -//│ AST: App(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(/),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2)))))))))))))))),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(3)))))) +//│ AST: App(App(Var(+),Tup(List((None,Fld(_,App(App(Var(+),Tup(List((None,Fld(_,IntLit(1)))))),Tup(List((None,Fld(_,App(App(Var(/),Tup(List((None,Fld(_,IntLit(2)))))),Tup(List((None,Fld(_,IntLit(2)))))))))))))))),Tup(List((None,Fld(_,IntLit(3)))))) //│ ╔══[ERROR] Type mismatch in operator application: //│ ║ l.20: 1 + 2 / 2 + 3 //│ ║ ^^^^^^^^^ @@ -36,7 +36,7 @@ 1 |> 2 || 3 //│ Parsed: ||(|>(1,)(2,),)(3,); //│ Desugared: ||(|>(1,)(2,),)(3,) -//│ AST: App(App(Var(||),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(|>),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(2))))))))))),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(3)))))) +//│ AST: App(App(Var(||),Tup(List((None,Fld(_,App(App(Var(|>),Tup(List((None,Fld(_,IntLit(1)))))),Tup(List((None,Fld(_,IntLit(2))))))))))),Tup(List((None,Fld(_,IntLit(3)))))) //│ ╔══[ERROR] identifier not found: |> //│ ║ l.36: 1 |> 2 || 3 //│ ╙── ^^ @@ -54,7 +54,7 @@ true || false && true || false //│ Parsed: ||(||(true,)(&&(false,)(true,),),)(false,); //│ Desugared: ||(||(true,)(&&(false,)(true,),),)(false,) -//│ AST: App(App(Var(||),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(||),Tup(List((None,Fld(FldFlags(false,false,false),Var(true)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(&&),Tup(List((None,Fld(FldFlags(false,false,false),Var(false)))))),Tup(List((None,Fld(FldFlags(false,false,false),Var(true)))))))))))))))),Tup(List((None,Fld(FldFlags(false,false,false),Var(false)))))) +//│ AST: App(App(Var(||),Tup(List((None,Fld(_,App(App(Var(||),Tup(List((None,Fld(_,Var(true)))))),Tup(List((None,Fld(_,App(App(Var(&&),Tup(List((None,Fld(_,Var(false)))))),Tup(List((None,Fld(_,Var(true)))))))))))))))),Tup(List((None,Fld(_,Var(false)))))) //│ res: bool //│ = true diff --git a/shared/src/test/diff/nu/AbstractClasses.mls b/shared/src/test/diff/nu/AbstractClasses.mls index 96dcb79c9..540f361d7 100644 --- a/shared/src/test/diff/nu/AbstractClasses.mls +++ b/shared/src/test/diff/nu/AbstractClasses.mls @@ -51,7 +51,7 @@ new Foo(1) { fun f = id } //│ ╙── ^^^^^^^^^^^^^^^^^^^^^^^^^ //│ error //│ Code generation encountered an error: -//│ cannot generate code for term Rft(App(NuNew(Var(Foo)),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1)))))),TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Var(id)))))) +//│ cannot generate code for term Rft(App(NuNew(Var(Foo)),Tup(List((None,Fld(_,IntLit(1)))))),TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Var(id)))))) abstract class Bar extends Foo(1) diff --git a/shared/src/test/diff/nu/BadBlocks.mls b/shared/src/test/diff/nu/BadBlocks.mls index 2e9898637..b76b35c08 100644 --- a/shared/src/test/diff/nu/BadBlocks.mls +++ b/shared/src/test/diff/nu/BadBlocks.mls @@ -176,5 +176,5 @@ fun test = (new { //│ ╙── ^ //│ fun test: error //│ Code generation encountered an error: -//│ Unsupported `new` class term: Bra(true,Rcd(List((Var(res),Fld(FldFlags(false,false,true),Var(res)))))) +//│ Unsupported `new` class term: Bra(true,Rcd(List((Var(res),Fld(g,Var(res)))))) diff --git a/shared/src/test/diff/nu/LamPatterns.mls b/shared/src/test/diff/nu/LamPatterns.mls index 0b4537909..7458108e6 100644 --- a/shared/src/test/diff/nu/LamPatterns.mls +++ b/shared/src/test/diff/nu/LamPatterns.mls @@ -14,7 +14,7 @@ Some(x) => x //│ ╙── ^ //│ error -> error //│ Code generation encountered an error: -//│ term App(Var(Some),Tup(List((None,Fld(FldFlags(false,false,false),Var(x)))))) is not a valid pattern +//│ term App(Var(Some),Tup(List((None,Fld(_,Var(x)))))) is not a valid pattern :js // FIXME type diff --git a/shared/src/test/diff/nu/OverrideShorthand.mls b/shared/src/test/diff/nu/OverrideShorthand.mls index 5f3392d15..2bd823530 100644 --- a/shared/src/test/diff/nu/OverrideShorthand.mls +++ b/shared/src/test/diff/nu/OverrideShorthand.mls @@ -10,7 +10,7 @@ class Pair(lhs: Int, rhs: Int) :e fun f(override Pair(x, y)) = x + y //│ |#fun| |f|(|#override| |Pair|(|x|,| |y|)|)| |#=| |x| |+| |y| -//│ AST: TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(_$0))))),If(IfOpApp(Var(_$0),Var(is),IfThen(App(Var(Pair),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))))),Some(App(Sel(Super(),Var(f)),Tup(List((None,Fld(FldFlags(false,false,false),Var(_$0))))))))))))) +//│ AST: TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(_$0))))),If(IfOpApp(Var(_$0),Var(is),IfThen(App(Var(Pair),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))))),Some(App(Sel(Super(),Var(f)),Tup(List((None,Fld(_,Var(_$0))))))))))))) //│ Parsed: fun f = (_$0,) => if _$0 is (Pair(x, y,)) then +(x, y,) else (super).f(_$0,); //│ ╔══[ERROR] identifier not found: super //│ ║ l.11: fun f(override Pair(x, y)) = x + y @@ -46,7 +46,7 @@ fun f(override Pair(x, y), z) = x + y //│ ╙── ^ //│ fun f: (error, anything) -> Int //│ Code generation encountered an error: -//│ term App(Var(Pair),Tup(List((None,Fld(FldFlags(false,false,false),Var(x))), (None,Fld(FldFlags(false,false,false),Var(y)))))) is not a valid pattern +//│ term App(Var(Pair),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))) is not a valid pattern // TODO diff --git a/shared/src/test/diff/nu/RightAssocOps.mls b/shared/src/test/diff/nu/RightAssocOps.mls index f6738db61..b692e7fb0 100644 --- a/shared/src/test/diff/nu/RightAssocOps.mls +++ b/shared/src/test/diff/nu/RightAssocOps.mls @@ -30,7 +30,7 @@ fun (++) conc(xs, ys) = [xs, ys] :p 1 +: "a" ++ "b" :+ 2 //│ |1| |+:| |"a"| |++| |"b"| |:+| |2| -//│ AST: TypingUnit(List(App(Var(+:),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(Var(:+),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(++),Tup(List((None,Fld(FldFlags(false,false,false),StrLit(a))), (None,Fld(FldFlags(false,false,false),StrLit(b)))))))), (None,Fld(FldFlags(false,false,false),IntLit(2))))))))))))) +//│ AST: TypingUnit(List(App(Var(+:),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(Var(:+),Tup(List((None,Fld(_,App(Var(++),Tup(List((None,Fld(_,StrLit(a))), (None,Fld(_,StrLit(b)))))))), (None,Fld(_,IntLit(2))))))))))))) //│ Parsed: +:(1, :+(++("a", "b",), 2,),); //│ [[Int], [["a", "b"], [Int]]] //│ res @@ -39,7 +39,7 @@ fun (++) conc(xs, ys) = [xs, ys] :p 1 +: "a" :+ 2 ++ "b" //│ |1| |+:| |"a"| |:+| |2| |++| |"b"| -//│ AST: TypingUnit(List(App(Var(+:),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(Var(++),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(:+),Tup(List((None,Fld(FldFlags(false,false,false),StrLit(a))), (None,Fld(FldFlags(false,false,false),IntLit(2)))))))), (None,Fld(FldFlags(false,false,false),StrLit(b))))))))))))) +//│ AST: TypingUnit(List(App(Var(+:),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(Var(++),Tup(List((None,Fld(_,App(Var(:+),Tup(List((None,Fld(_,StrLit(a))), (None,Fld(_,IntLit(2)))))))), (None,Fld(_,StrLit(b))))))))))))) //│ Parsed: +:(1, ++(:+("a", 2,), "b",),); //│ [[Int], [["a", [Int]], "b"]] //│ res @@ -49,7 +49,7 @@ fun (++) conc(xs, ys) = [xs, ys] :e 1 +: "a" ++ 2 +: "b" //│ |1| |+:| |"a"| |++| |2| |+:| |"b"| -//│ AST: TypingUnit(List(App(Var(+:),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(1))), (None,Fld(FldFlags(false,false,false),App(Var(+:),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(++),Tup(List((None,Fld(FldFlags(false,false,false),StrLit(a))), (None,Fld(FldFlags(false,false,false),IntLit(2)))))))), (None,Fld(FldFlags(false,false,false),StrLit(b))))))))))))) +//│ AST: TypingUnit(List(App(Var(+:),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(Var(+:),Tup(List((None,Fld(_,App(Var(++),Tup(List((None,Fld(_,StrLit(a))), (None,Fld(_,IntLit(2)))))))), (None,Fld(_,StrLit(b))))))))))))) //│ Parsed: +:(1, +:(++("a", 2,), "b",),); //│ ╔══[ERROR] Type mismatch in operator application: //│ ║ l.50: 1 +: "a" ++ 2 +: "b" diff --git a/shared/src/test/diff/ucs/LeadingAnd.mls b/shared/src/test/diff/ucs/LeadingAnd.mls index bb6ac93e0..2303e4ebb 100644 --- a/shared/src/test/diff/ucs/LeadingAnd.mls +++ b/shared/src/test/diff/ucs/LeadingAnd.mls @@ -23,7 +23,7 @@ fun f(a, b) = if a is Some(av) and b is Some(bv) then av + bv //│ |#fun| |f|(|a|,| |b|)| |#=| |#if| |a| |is| |Some|(|av|)|→|and| |b| |is| |Some|(|bv|)|↵|#then| |av| |+| |bv|←| -//│ AST: TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),Var(b))))),If(IfOpApp(Var(a),Var(is),IfOpsApp(App(Var(Some),Tup(List((None,Fld(FldFlags(false,false,false),Var(av)))))),List((Var(and),IfThen(App(Var(is),Tup(List((None,Fld(FldFlags(false,false,false),Var(b))), (None,Fld(FldFlags(false,false,false),App(Var(Some),Tup(List((None,Fld(FldFlags(false,false,false),Var(bv))))))))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(av))), (None,Fld(FldFlags(false,false,false),Var(bv))))))))))),None)))))) +//│ AST: TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(a))), (None,Fld(_,Var(b))))),If(IfOpApp(Var(a),Var(is),IfOpsApp(App(Var(Some),Tup(List((None,Fld(_,Var(av)))))),List((Var(and),IfThen(App(Var(is),Tup(List((None,Fld(_,Var(b))), (None,Fld(_,App(Var(Some),Tup(List((None,Fld(_,Var(bv))))))))))),App(Var(+),Tup(List((None,Fld(_,Var(av))), (None,Fld(_,Var(bv))))))))))),None)))))) //│ Parsed: fun f = (a, b,) => if a is Some(av,) ‹· and (is(b, Some(bv,),)) then +(av, bv,)›; //│ fun f: (Some[Int], Some[Int]) -> Int @@ -34,7 +34,7 @@ fun f(a, b) = if a is and b is Some(bv) then av + bv //│ |#fun| |f|(|a|,| |b|)| |#=| |#if| |a| |is|→|Some|(|av|)|→|and| |b| |is| |Some|(|bv|)|↵|#then| |av| |+| |bv|←|←| -//│ AST: TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),Var(b))))),If(IfOpApp(Var(a),Var(is),IfBlock(List(Left(IfOpsApp(App(Var(Some),Tup(List((None,Fld(FldFlags(false,false,false),Var(av)))))),List((Var(and),IfThen(App(Var(is),Tup(List((None,Fld(FldFlags(false,false,false),Var(b))), (None,Fld(FldFlags(false,false,false),App(Var(Some),Tup(List((None,Fld(FldFlags(false,false,false),Var(bv))))))))))),App(Var(+),Tup(List((None,Fld(FldFlags(false,false,false),Var(av))), (None,Fld(FldFlags(false,false,false),Var(bv)))))))))))))),None)))))) +//│ AST: TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(a))), (None,Fld(_,Var(b))))),If(IfOpApp(Var(a),Var(is),IfBlock(List(Left(IfOpsApp(App(Var(Some),Tup(List((None,Fld(_,Var(av)))))),List((Var(and),IfThen(App(Var(is),Tup(List((None,Fld(_,Var(b))), (None,Fld(_,App(Var(Some),Tup(List((None,Fld(_,Var(bv))))))))))),App(Var(+),Tup(List((None,Fld(_,Var(av))), (None,Fld(_,Var(bv)))))))))))))),None)))))) //│ Parsed: fun f = (a, b,) => if a is ‹Some(av,) ‹· and (is(b, Some(bv,),)) then +(av, bv,)››; //│ ╔══[ERROR] Illegal pattern `and` //│ ║ l.34: and b is Some(bv) diff --git a/shared/src/test/diff/ucs/SplitOps.mls b/shared/src/test/diff/ucs/SplitOps.mls index 6a88e2d49..c966e4b0a 100644 --- a/shared/src/test/diff/ucs/SplitOps.mls +++ b/shared/src/test/diff/ucs/SplitOps.mls @@ -93,10 +93,10 @@ fun f(a, b, c) = if a == 0 and b is B() and c is C() then 0 //│ |#fun| |f|(|a|,| |b|,| |c|)| |#=|→|#if| |a|→|==| |0| |and| |b| |is| |B|(||)| |and| |c| |is| |C|(||)| |#then| |0|←|←| -//│ AST: TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),Var(b))), (None,Fld(FldFlags(false,false,false),Var(c))))),Blk(List(If(IfOpsApp(Var(a),List((Var(==),IfThen(App(App(Var(and),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(and),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(is),Tup(List((None,Fld(FldFlags(false,false,false),Var(b)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(B),Tup(List()))))))))))))))))),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(is),Tup(List((None,Fld(FldFlags(false,false,false),Var(c)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(C),Tup(List())))))))))))),IntLit(0))))),None)))))))) +//│ AST: TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(a))), (None,Fld(_,Var(b))), (None,Fld(_,Var(c))))),Blk(List(If(IfOpsApp(Var(a),List((Var(==),IfThen(App(App(Var(and),Tup(List((None,Fld(_,App(App(Var(and),Tup(List((None,Fld(_,IntLit(0)))))),Tup(List((None,Fld(_,App(App(Var(is),Tup(List((None,Fld(_,Var(b)))))),Tup(List((None,Fld(_,App(Var(B),Tup(List()))))))))))))))))),Tup(List((None,Fld(_,App(App(Var(is),Tup(List((None,Fld(_,Var(c)))))),Tup(List((None,Fld(_,App(Var(C),Tup(List())))))))))))),IntLit(0))))),None)))))))) //│ Parsed: fun f = (a, b, c,) => {if a ‹· == (and(and(0,)(is(b,)(B(),),),)(is(c,)(C(),),)) then 0›}; //│ Desugared: rec def f: (a, b, c,) => {if a ‹· == (and(and(0,)(is(b,)(B(),),),)(is(c,)(C(),),)) then 0›} -//│ AST: Def(true,Var(f),Left(Lam(Tup(List((None,Fld(FldFlags(false,false,false),Var(a))), (None,Fld(FldFlags(false,false,false),Var(b))), (None,Fld(FldFlags(false,false,false),Var(c))))),Blk(List(If(IfOpsApp(Var(a),List((Var(==),IfThen(App(App(Var(and),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(and),Tup(List((None,Fld(FldFlags(false,false,false),IntLit(0)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(is),Tup(List((None,Fld(FldFlags(false,false,false),Var(b)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(B),Tup(List()))))))))))))))))),Tup(List((None,Fld(FldFlags(false,false,false),App(App(Var(is),Tup(List((None,Fld(FldFlags(false,false,false),Var(c)))))),Tup(List((None,Fld(FldFlags(false,false,false),App(Var(C),Tup(List())))))))))))),IntLit(0))))),None))))),true) +//│ AST: Def(true,Var(f),Left(Lam(Tup(List((None,Fld(_,Var(a))), (None,Fld(_,Var(b))), (None,Fld(_,Var(c))))),Blk(List(If(IfOpsApp(Var(a),List((Var(==),IfThen(App(App(Var(and),Tup(List((None,Fld(_,App(App(Var(and),Tup(List((None,Fld(_,IntLit(0)))))),Tup(List((None,Fld(_,App(App(Var(is),Tup(List((None,Fld(_,Var(b)))))),Tup(List((None,Fld(_,App(Var(B),Tup(List()))))))))))))))))),Tup(List((None,Fld(_,App(App(Var(is),Tup(List((None,Fld(_,Var(c)))))),Tup(List((None,Fld(_,App(Var(C),Tup(List())))))))))))),IntLit(0))))),None))))),true) //│ ╔══[ERROR] The case when this is false is not handled: ==(a,)(0,) //│ ║ l.93: if a //│ ║ ^ From 947ea51dc675b9ce809d040c19518fd71fd61513 Mon Sep 17 00:00:00 2001 From: Luyu Cheng Date: Mon, 1 Jan 2024 20:14:38 +0800 Subject: [PATCH 07/11] Reset the number of lines of stack trace to 10 --- shared/src/test/scala/mlscript/DiffTests.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/src/test/scala/mlscript/DiffTests.scala b/shared/src/test/scala/mlscript/DiffTests.scala index b0896150d..1defcdd46 100644 --- a/shared/src/test/scala/mlscript/DiffTests.scala +++ b/shared/src/test/scala/mlscript/DiffTests.scala @@ -1051,7 +1051,7 @@ class DiffTests err.getStackTrace().take( if (mode.fullExceptionStack) Int.MaxValue else if (mode.fixme || err.isInstanceOf[StackOverflowError]) 0 - else 50 + else 10 ).map("\n" + "\tat: " + _).mkString) } finally { typer.dbg = false From e1af9db839ea3b274304755a33328fc8c47f00f6 Mon Sep 17 00:00:00 2001 From: Luyu Cheng Date: Mon, 1 Jan 2024 20:19:51 +0800 Subject: [PATCH 08/11] Remove parsed output from compiler tests --- compiler/shared/test/diff/LambLift.mls | 12 +-- compiler/shared/test/diff/LiftType.mls | 15 ++-- compiler/shared/test/diff/Lifter.mls | 45 ++++------- compiler/shared/test/diff/LifterBlks.mls | 54 +++++-------- compiler/shared/test/diff/mono.mls | 81 +++++++------------ .../test/scala/mlscript/compiler/Test.scala | 2 - 6 files changed, 69 insertions(+), 140 deletions(-) diff --git a/compiler/shared/test/diff/LambLift.mls b/compiler/shared/test/diff/LambLift.mls index ec08d4f08..81fecb52d 100644 --- a/compiler/shared/test/diff/LambLift.mls +++ b/compiler/shared/test/diff/LambLift.mls @@ -9,8 +9,7 @@ fun foo() = (new Foo()).bar local(1) foo() -//│ Parsed: -//│ 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(_,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(_,Var(x))), (None,Fld(_,App(Var(foo),Tup(List())))))))))))), Sel(Bra(false,App(NuNew(Var(Foo)),Tup(List()))),Var(bar))))))), App(Var(local),Tup(List((None,Fld(_,IntLit(1))))))))))), App(Var(foo),Tup(List())))) +//│ //│ Lifted: //│ TypingUnit { //│ class Foo$1([x,]) {fun bar = () => +((this).x, foo$1(),)} @@ -27,8 +26,7 @@ foo() fun foo(f) = f(1) foo(x => x+1) -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(f))))),Blk(List(App(Var(f),Tup(List((None,Fld(_,IntLit(1))))))))))), App(Var(foo),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1)))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class Lambda1$2$1([]) {fun apply = (x,) => +(x, 1,)} @@ -45,8 +43,7 @@ fun foo(x) = f(x) bar(y => y+x) foo(1) -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(NuFunDef(Some(false),Var(bar),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(f))))),Blk(List(App(Var(f),Tup(List((None,Fld(_,Var(x))))))))))), App(Var(bar),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(y))))),App(Var(+),Tup(List((None,Fld(_,Var(y))), (None,Fld(_,Var(x))))))))))))))))), App(Var(foo),Tup(List((None,Fld(_,IntLit(1)))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class Lambda1$3$1([x,]) {fun apply = (y,) => +(y, (this).x,)} @@ -67,8 +64,7 @@ class A(y: Int){ fun app(a) = foo(z => a.bar(z)) app(new A(1)) -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(f))))),Blk(List(App(Var(f),Tup(List((None,Fld(_,IntLit(1))))))))))), NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((Some(Var(y)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(z))))),App(Var(+),Tup(List((None,Fld(_,Var(y))), (None,Fld(_,Var(z)))))))))))), NuFunDef(None,Var(app),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(a))))),Blk(List(App(Var(foo),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(z))))),App(Sel(Var(a),Var(bar)),Tup(List((None,Fld(_,Var(z))))))))))))))))), App(Var(app),Tup(List((None,Fld(_,App(NuNew(Var(A)),Tup(List((None,Fld(_,IntLit(1))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class A$1([y: Int,]) {fun bar = (z,) => +((this).y, z,)} diff --git a/compiler/shared/test/diff/LiftType.mls b/compiler/shared/test/diff/LiftType.mls index 4f2bebe4d..e8a5206b5 100644 --- a/compiler/shared/test/diff/LiftType.mls +++ b/compiler/shared/test/diff/LiftType.mls @@ -7,8 +7,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(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(_,Lam(Tup(List((None,Fld(_,Var(A))))),Var(A)))))),Asc(App(Var(f),Tup(List((None,Fld(_,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,]) {} @@ -25,8 +24,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(List(NuTypeDef(Cls,TypeName(CTX),List(),Some(Tup(List((None,Fld(_,Var(x))), (None,Fld(_,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(_,Tup(List((None,Fld(_,Var(A))), (None,Fld(_,Var(B))))))))),Asc(Tup(List((None,Fld(_,Sel(Var(any),Var(_2)))), (None,Fld(_,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} @@ -44,8 +42,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(List(NuTypeDef(Cls,TypeName(CTX),List(),Some(Tup(List((None,Fld(_,Var(x))), (None,Fld(_,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(_,Bra(true,Rcd(List((Var(p1),Fld(_,Var(A))), (Var(p2),Fld(_,Var(B)))))))))),Asc(Tup(List((None,Fld(_,Sel(Var(any),Var(p2)))), (None,Fld(_,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} @@ -63,8 +60,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(List(NuTypeDef(Cls,TypeName(CTX),List(),Some(Tup(List((None,Fld(_,Var(x))), (None,Fld(_,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(_,Tup(List((None,Fld(_,Var(A))), (None,Fld(_,TyApp(Var(B),List(TypeName(A))))))))))),Asc(Tup(List((None,Fld(_,Var(any))), (None,Fld(_,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} @@ -85,8 +81,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(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(_,Var(x))), (None,Fld(_,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(_,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. //│ diff --git a/compiler/shared/test/diff/Lifter.mls b/compiler/shared/test/diff/Lifter.mls index a1eb51a20..f46f6611e 100644 --- a/compiler/shared/test/diff/Lifter.mls +++ b/compiler/shared/test/diff/Lifter.mls @@ -27,8 +27,7 @@ class A(x) { } //│ |#class| |A|(|x|)| |{|→|#class| |B|(|y|)| |{|→|#fun| |getX| |#=| |x|↵|#fun| |getB1| |#=| |B1|(|y|)|↵|#class| |C|(|z|)| |{|→|#fun| |inc|(||)| |#=| |x| |+| |1|↵|#fun| |getY| |#=| |y|↵|#fun| |getA| |#=| |A|(|z|)|↵|#fun| |getB|(|w|)| |#=| |B|(|w|)|↵|#fun| |getC| |#=| |#new| |C|(|inc|(||)|)|↵|#fun| |getSelf| |#=| |this|←|↵|}|←|↵|}|↵|#class| |B1|(|y|)| |{|→|#fun| |getX| |#=| |x|↵|#fun| |getY| |#=| |y|↵|#fun| |getB| |#=| |#new| |B|(|y|)|↵|#fun| |getB1| |#=| |#new| |B1|(|y|)|←|↵|}|↵|#fun| |getB| |#=| |#new| |B|(|x|)|↵|#fun| |getB2|(|y|)| |#=| |B1|(|y|)|↵|#fun| |getB3|(|z|)| |#=| |getB2|(|z|)|↵|#fun| |getA| |#=| |A|(|x|)|←|↵|}| //│ Parsed: {class A(x,) {class B(y,) {fun getX = x; fun getB1 = B1(y,); class C(z,) {fun inc = () => +(x, 1,); fun getY = y; fun getA = A(z,); fun getB = (w,) => B(w,); fun getC = (new C)(inc(),); fun getSelf = this}}; class B1(y,) {fun getX = x; fun getY = y; fun getB = (new B)(y,); fun getB1 = (new B1)(y,)}; fun getB = (new B)(x,); fun getB2 = (y,) => B1(y,); fun getB3 = (z,) => getB2(z,); fun getA = A(x,)}} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(_,Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),Some(Tup(List((None,Fld(_,Var(y)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(getX),None,List(),Left(Var(x))), NuFunDef(None,Var(getB1),None,List(),Left(App(Var(B1),Tup(List((None,Fld(_,Var(y)))))))), NuTypeDef(Cls,TypeName(C),List(),Some(Tup(List((None,Fld(_,Var(z)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(inc),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1))))))))), NuFunDef(None,Var(getY),None,List(),Left(Var(y))), NuFunDef(None,Var(getA),None,List(),Left(App(Var(A),Tup(List((None,Fld(_,Var(z)))))))), NuFunDef(None,Var(getB),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(w))))),App(Var(B),Tup(List((None,Fld(_,Var(w))))))))), NuFunDef(None,Var(getC),None,List(),Left(App(NuNew(Var(C)),Tup(List((None,Fld(_,App(Var(inc),Tup(List()))))))))), NuFunDef(None,Var(getSelf),None,List(),Left(Var(this))))))))), NuTypeDef(Cls,TypeName(B1),List(),Some(Tup(List((None,Fld(_,Var(y)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(getX),None,List(),Left(Var(x))), NuFunDef(None,Var(getY),None,List(),Left(Var(y))), NuFunDef(None,Var(getB),None,List(),Left(App(NuNew(Var(B)),Tup(List((None,Fld(_,Var(y)))))))), NuFunDef(None,Var(getB1),None,List(),Left(App(NuNew(Var(B1)),Tup(List((None,Fld(_,Var(y))))))))))), NuFunDef(None,Var(getB),None,List(),Left(App(NuNew(Var(B)),Tup(List((None,Fld(_,Var(x)))))))), NuFunDef(None,Var(getB2),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(y))))),App(Var(B1),Tup(List((None,Fld(_,Var(y))))))))), NuFunDef(None,Var(getB3),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(z))))),App(Var(getB2),Tup(List((None,Fld(_,Var(z))))))))), NuFunDef(None,Var(getA),None,List(),Left(App(Var(A),Tup(List((None,Fld(_,Var(x))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class A$1_B$2_C$4([par$A$1_B$2, z, x,]) { @@ -67,8 +66,7 @@ class A(x) { } //│ |#class| |A|(|x|)| |{|→|#class| |B|(|y|)| |{|→|#class| |C|(|z|)| |{|→|#fun| |sum| |#=| |x| |+| |y| |+| |z|←|↵|}|←|↵|}|←|↵|}| //│ Parsed: {class A(x,) {class B(y,) {class C(z,) {fun sum = +(+(x, y,), z,)}}}} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(_,Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),Some(Tup(List((None,Fld(_,Var(y)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(C),List(),Some(Tup(List((None,Fld(_,Var(z)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(sum),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))))), (None,Fld(_,Var(z))))))))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class A$1_B$2_C$3([par$A$1_B$2, z, x,]) { @@ -107,8 +105,7 @@ new C{ } //│ |#class| |A|(|x|)| |{|→|#class| |B|{|→|#fun| |foo| |#=| |1|↵|#fun| |bar| |#=| |11|←|↵|}|↵|#fun| |getB| |#=| |#new| |B|{|→|#fun| |foo| |#=| |2|↵|#fun| |bar| |#=| |12|←|↵|}|↵|#fun| |bar| |#=| |13|←|↵|}|↵|#class| |C|#:| |A|{|→|#fun| |getB| |#=| |#new| |B|{|→|#fun| |foo| |#=| |3|↵|#fun| |bar| |#=| |14|←|↵|}|↵|#fun| |bar| |#=| |15|←|↵|}|↵|#new| |C|{|→|#fun| |getB| |#=| |#new| |B|{|→|#fun| |foo| |#=| |4|↵|#fun| |bar| |#=| |16|←|↵|}|↵|#fun| |bar| |#=| |17|←|↵|}| //│ Parsed: {class A(x,) {class B {fun foo = 1; fun bar = 11}; fun getB = new B { ‹fun foo = 2; fun bar = 12› }; fun bar = 13}; class C: A {fun getB = new B { ‹fun foo = 3; fun bar = 14› }; fun bar = 15}; new C { ‹fun getB = new B { ‹fun foo = 4; fun bar = 16› }; fun bar = 17› }} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(_,Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(1))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(11)))))), NuFunDef(None,Var(getB),None,List(),Left(Rft(NuNew(Var(B)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(2))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(12)))))))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(13)))))), NuTypeDef(Cls,TypeName(C),List(),None,None,Some(TypeName(A)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(getB),None,List(),Left(Rft(NuNew(Var(B)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(3))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(14)))))))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(15)))))), Rft(NuNew(Var(C)),TypingUnit(List(NuFunDef(None,Var(getB),None,List(),Left(Rft(NuNew(Var(B)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(4))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(16)))))))), NuFunDef(None,Var(bar),None,List(),Left(IntLit(17)))))))) +//│ //│ Lifted: //│ Lifting failed: mlscript.codegen.CodeGenError: Cannot find type B. Class values are not supported in lifter. //│ @@ -124,8 +121,7 @@ class Parent(x) { } //│ |#class| |Parent|‹|T|,| |U|,| |V|›|(|x|)| |{| |→|#fun| |foo|(|x|#:| |Int|)|#:| |T| |#=| |x|+|1|↵|#class| |Inner|‹|W|›|(|y|#:| |Int|)|{|→|#fun| |bar|(|z|#:| |U|)| |#=| |foo|(|y|)|↵|#fun| |boo|(|z|#:| |W|)| |#=| |z|←|↵|}|←|↵|}| //│ Parsed: {class Parent‹T, U, V›(x,) {fun foo = (x: Int,) => +(x, 1,) : T; class Inner‹W›(y: Int,) {fun bar = (z: U,) => foo(y,); fun boo = (z: W,) => z}}} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Parent),List((None,TypeName(T)), (None,TypeName(U)), (None,TypeName(V))),Some(Tup(List((None,Fld(_,Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(_,Var(Int))))),Asc(App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1)))))),TypeName(T))))), NuTypeDef(Cls,TypeName(Inner),List((None,TypeName(W))),Some(Tup(List((Some(Var(y)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(Lam(Tup(List((Some(Var(z)),Fld(_,Var(U))))),App(Var(foo),Tup(List((None,Fld(_,Var(y))))))))), NuFunDef(None,Var(boo),None,List(),Left(Lam(Tup(List((Some(Var(z)),Fld(_,Var(W))))),Var(z)))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class Parent$1_Inner$2[W,U]([par$Parent$1, y: Int,]) { @@ -147,8 +143,7 @@ class A(x: Int): ({a1: Int} & B & D(x)) { } //│ |#class| |B|‹|T|›| |{||}|↵|#class| |C| |{||}|↵|#class| |D|(|y|#:| |Int|)| |{||}|↵|#class| |A|‹|T|,| |U|›|(|x|#:| |Int|)|#:| |(|{|a1|#:| |Int|}| |&| |B|‹|T|›| |&| |D|(|x|)|)| |{|→|#fun| |getA|(||)| |#=| |#new| |C|{|→|#fun| |foo|(|x|#:| |T|)| |#=| |x|←|↵|}|←|↵|}| //│ Parsed: {class B‹T› {}; class C {}; class D(y: Int,) {}; class A‹T, U›(x: Int,): {a1: Int} & B[T] & D[x] {fun getA = () => new C { ‹fun foo = (x: T,) => x› }}} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(B),List((None,TypeName(T))),None,None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(C),List(),None,None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(D),List(),Some(Tup(List((Some(Var(y)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(A),List((None,TypeName(T)), (None,TypeName(U))),Some(Tup(List((Some(Var(x)),Fld(_,Var(Int)))))),None,Some(Inter(Inter(Record(List((Var(a1),Field(None,TypeName(Int))))),AppliedType(TypeName(B),List(TypeName(T)))),AppliedType(TypeName(D),List(TypeName(x))))),List(),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(Lam(Tup(List()),Rft(NuNew(Var(C)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(_,Var(T))))),Var(x))))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class B$1[T]([]) {} @@ -169,8 +164,7 @@ class A(x: Int) extends {a1: Int}, B, D(x){ } //│ |#class| |B|‹|T|›| |{||}|↵|#class| |C| |{||}|↵|#class| |D|(|y|#:| |Int|)| |{||}|↵|#class| |A|‹|T|,| |U|›|(|x|#:| |Int|)| |#extends| |{|a1|#:| |Int|}|,| |B|‹|T|›|,| |D|(|x|)|{|→|#fun| |getA|(||)| |#=| |#new| |C|{|→|#fun| |foo|(|x|)| |#=| |x|←|↵|}|←|↵|}| //│ Parsed: {class B‹T› {}; class C {}; class D(y: Int,) {}; class A‹T, U›(x: Int,): '{' {a1: Int} '}', B‹T›, D(x,) {fun getA = () => new C { ‹fun foo = (x,) => x› }}} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(B),List((None,TypeName(T))),None,None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(C),List(),None,None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(D),List(),Some(Tup(List((Some(Var(y)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(A),List((None,TypeName(T)), (None,TypeName(U))),Some(Tup(List((Some(Var(x)),Fld(_,Var(Int)))))),None,None,List(Bra(true,Rcd(List((Var(a1),Fld(_,Var(Int)))))), TyApp(Var(B),List(TypeName(T))), App(Var(D),Tup(List((None,Fld(_,Var(x))))))),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(Lam(Tup(List()),Rft(NuNew(Var(C)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Var(x))))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class B$1[T]([]) {} @@ -189,8 +183,7 @@ class Child(x): ({ age: T } & { name: String}) { } //│ |#class| |Child|‹|T|,| |U|›|(|x|)|#:| |(|{| |age|#:| |T| |}| |&| |{| |name|#:| |String|}|)| |{|→|#class| |Inner|{|→|#fun| |foo| |#=| |age|←|↵|}|↵|#fun| |bar| |#=| |age|↵|#fun| |boo| |#=| |#new| |Inner|←|↵|}| //│ Parsed: {class Child‹T, U›(x,): {age: T} & {name: String} {class Inner {fun foo = age}; fun bar = age; fun boo = new Inner}} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Child),List((None,TypeName(T)), (None,TypeName(U))),Some(Tup(List((None,Fld(_,Var(x)))))),None,Some(Inter(Record(List((Var(age),Field(None,TypeName(T))))),Record(List((Var(name),Field(None,TypeName(String))))))),List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(Inner),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Var(age)))))), NuFunDef(None,Var(bar),None,List(),Left(Var(age))), NuFunDef(None,Var(boo),None,List(),Left(NuNew(Var(Inner))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class Child$1_Inner$2([par$Child$1, age,]) {fun foo = () => (this).age} @@ -212,8 +205,7 @@ new A(0) { } //│ |#class| |A|(|x|#:| |Int|)| |{|→|#fun| |getA|#:| |Int| |#=| |0|↵|#fun| |getA1| |#=| |1|←|↵|}|↵|#new| |A|(|0|)| |{|→|#fun| |getA| |#=| |3|↵|#fun| |getA2| |#=| |2|←|↵|}| //│ Parsed: {class A(x: Int,) {fun getA = 0 : Int; fun getA1 = 1}; (new A)(0,) { ‹fun getA = 3; fun getA2 = 2› }} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((Some(Var(x)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(Asc(IntLit(0),TypeName(Int)))), NuFunDef(None,Var(getA1),None,List(),Left(IntLit(1)))))), Rft(App(NuNew(Var(A)),Tup(List((None,Fld(_,IntLit(0)))))),TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(IntLit(3))), NuFunDef(None,Var(getA2),None,List(),Left(IntLit(2)))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class A$1([x: Int,]) {fun getA = () => 0 : Int; fun getA1 = () => 1} @@ -233,8 +225,7 @@ new A(1) { } //│ |#class| |A|(|x|)| |{|→|#class| |B|(|y|)| |{| |}|←|↵|}|↵|#new| |A|(|1|)| |{|→|#fun| |getB| |#=| |#new| |B|(|2|)|{|→|#fun| |getB| |#=| |#new| |B|(|3|)|←|↵|}|←|↵|}| //│ Parsed: {class A(x,) {class B(y,) {}}; (new A)(1,) { ‹fun getB = (new B)(2,) { ‹fun getB = (new B)(3,)› }› }} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(_,Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),Some(Tup(List((None,Fld(_,Var(y)))))),None,None,List(),None,None,TypingUnit(List()))))), Rft(App(NuNew(Var(A)),Tup(List((None,Fld(_,IntLit(1)))))),TypingUnit(List(NuFunDef(None,Var(getB),None,List(),Left(Rft(App(NuNew(Var(B)),Tup(List((None,Fld(_,IntLit(2)))))),TypingUnit(List(NuFunDef(None,Var(getB),None,List(),Left(App(NuNew(Var(B)),Tup(List((None,Fld(_,IntLit(3)))))))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1, y,]) {} @@ -266,8 +257,7 @@ new B{ } //│ |#class| |A| |{|→|#fun| |getA| |#=| |0|↵|#fun| |funcA| |#=| |10|←|↵|}|↵|#class| |B|#:| |A|{|→|#fun| |getA| |#=| |1|↵|#fun| |funcB| |#=| |11|←|↵|}|↵|#new| |A|↵|#new| |B|↵|#fun| |f|(|x|)| |#=| |#if| |x| |is| |A| |#then| |0| |#else| |1|↵|f|(|#new| |A|{|→|#fun| |getA| |#=| |2|←|↵|}|)|↵|#new| |B|{|→|#fun| |getA| |#=| |funcB|←|↵|}| //│ Parsed: {class A {fun getA = 0; fun funcA = 10}; class B: A {fun getA = 1; fun funcB = 11}; new A; new B; fun f = (x,) => if (is(x, A,)) then 0 else 1; f(new A { ‹fun getA = 2› },); new B { ‹fun getA = funcB› }} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(IntLit(0))), NuFunDef(None,Var(funcA),None,List(),Left(IntLit(10)))))), NuTypeDef(Cls,TypeName(B),List(),None,None,Some(TypeName(A)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(IntLit(1))), NuFunDef(None,Var(funcB),None,List(),Left(IntLit(11)))))), NuNew(Var(A)), NuNew(Var(B)), NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),If(IfThen(App(Var(is),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(A)))))),IntLit(0)),Some(IntLit(1)))))), App(Var(f),Tup(List((None,Fld(_,Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(IntLit(2))))))))))), Rft(NuNew(Var(B)),TypingUnit(List(NuFunDef(None,Var(getA),None,List(),Left(Var(funcB)))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class A$1([]) {fun getA = () => 0; fun funcA = () => 10} @@ -305,8 +295,7 @@ class A{ } //│ |#class| |A|{|→|#class| |B|{|→|#fun| |funB| |#=| |1|↵|#fun| |foo| |#=| |100|←|↵|}|↵|#class| |C|#:| |B|{|→|#fun| |funC| |#=| |2|↵|#fun| |foo| |#=| |1000|←|↵|}|↵|#class| |D|{|→|#fun| |funD| |#=| |3|↵|#fun| |foo| |#=| |10000| |↵|#class| |E|#:| |C|{|→|#fun| |funE| |#=| |4|↵|#fun| |foo| |#=| |100000|←|↵|}|↵|#class| |F|#:| |E|{|→|#fun| |funF| |#=| |5|↵|#fun| |foo| |#=| |1000000|←|↵|}|←|↵|}|←|↵|}| //│ Parsed: {class A {class B {fun funB = 1; fun foo = 100}; class C: B {fun funC = 2; fun foo = 1000}; class D {fun funD = 3; fun foo = 10000; class E: C {fun funE = 4; fun foo = 100000}; class F: E {fun funF = 5; fun foo = 1000000}}}} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(funB),None,List(),Left(IntLit(1))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(100)))))), NuTypeDef(Cls,TypeName(C),List(),None,None,Some(TypeName(B)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(funC),None,List(),Left(IntLit(2))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(1000)))))), NuTypeDef(Cls,TypeName(D),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(funD),None,List(),Left(IntLit(3))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(10000))), NuTypeDef(Cls,TypeName(E),List(),None,None,Some(TypeName(C)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(funE),None,List(),Left(IntLit(4))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(100000)))))), NuTypeDef(Cls,TypeName(F),List(),None,None,Some(TypeName(E)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(funF),None,List(),Left(IntLit(5))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(1000000)))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1,]) {fun funB = () => 1; fun foo = () => 100} @@ -348,8 +337,7 @@ class A{ } //│ |#class| |A|{|→|#class| |B|{|→|#fun| |funB| |#=| |1|↵|#fun| |foo| |#=| |100|←|↵|}|↵|#class| |C|#:| |B|{|→|#fun| |funC| |#=| |2|↵|#fun| |foo| |#=| |1000|↵|#fun| |getB| |#=| |#new| |B|←|↵|}|↵|#class| |D|{|→|#fun| |funD| |#=| |3|↵|#fun| |foo| |#=| |10000| |↵|#class| |E|#:| |C|{|→|#fun| |funE| |#=| |4|↵|#fun| |foo| |#=| |100000|↵|#fun| |getD| |#=| |#new| |D|←|↵|}|↵|#class| |F|#:| |E|{|→|#fun| |funF| |#=| |5|↵|#fun| |foo| |#=| |1000000|↵|#fun| |getE| |#=| |#new| |E|{|→|#fun| |foo| |#=| |0|←|↵|}|←|↵|}|←|↵|}|←|↵|}| //│ Parsed: {class A {class B {fun funB = 1; fun foo = 100}; class C: B {fun funC = 2; fun foo = 1000; fun getB = new B}; class D {fun funD = 3; fun foo = 10000; class E: C {fun funE = 4; fun foo = 100000; fun getD = new D}; class F: E {fun funF = 5; fun foo = 1000000; fun getE = new E { ‹fun foo = 0› }}}}} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(funB),None,List(),Left(IntLit(1))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(100)))))), NuTypeDef(Cls,TypeName(C),List(),None,None,Some(TypeName(B)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(funC),None,List(),Left(IntLit(2))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(1000))), NuFunDef(None,Var(getB),None,List(),Left(NuNew(Var(B))))))), NuTypeDef(Cls,TypeName(D),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(funD),None,List(),Left(IntLit(3))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(10000))), NuTypeDef(Cls,TypeName(E),List(),None,None,Some(TypeName(C)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(funE),None,List(),Left(IntLit(4))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(100000))), NuFunDef(None,Var(getD),None,List(),Left(NuNew(Var(D))))))), NuTypeDef(Cls,TypeName(F),List(),None,None,Some(TypeName(E)),List(),None,None,TypingUnit(List(NuFunDef(None,Var(funF),None,List(),Left(IntLit(5))), NuFunDef(None,Var(foo),None,List(),Left(IntLit(1000000))), NuFunDef(None,Var(getE),None,List(),Left(Rft(NuNew(Var(E)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(0))))))))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1,]) {fun funB = () => 1; fun foo = () => 100} @@ -383,8 +371,7 @@ class A{ new A //│ |#class| |A|{|→|#class| |B|{|→|#fun| |foo| |#=| |1|←|↵|}|↵|#fun| |bar| |#=| |#new| |B|←|↵|}|↵|#new| |A| //│ Parsed: {class A {class B {fun foo = 1}; fun bar = new B}; new A} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(1)))))), NuFunDef(None,Var(bar),None,List(),Left(NuNew(Var(B))))))), NuNew(Var(A)))) +//│ //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1,]) {fun foo = () => 1} @@ -408,8 +395,7 @@ let x = new A{ } //│ |#class| |A|(|x|)| |{|→|#fun| |foo| |#=| |0|↵|#fun| |bar| |#=| |x|←|↵|}|↵|#let| |x| |#=| |#new| |A|{|→|#fun| |foo| |#=| |1|↵|#fun| |newFun| |#=| |2|↵|#fun| |bar| |#=| |#new| |A|(|foo|)|{|→|#fun| |foo| |#=| |bar| |+| |1|↵|#fun| |bar2| |#=| |newFun| |+| |1|←|↵|}|←|↵|}| //│ Parsed: {class A(x,) {fun foo = 0; fun bar = x}; let x = new A { ‹fun foo = 1; fun newFun = 2; fun bar = (new A)(foo,) { ‹fun foo = +(bar, 1,); fun bar2 = +(newFun, 1,)› }› }} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(_,Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(0))), NuFunDef(None,Var(bar),None,List(),Left(Var(x)))))), NuFunDef(Some(false),Var(x),None,List(),Left(Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(1))), NuFunDef(None,Var(newFun),None,List(),Left(IntLit(2))), NuFunDef(None,Var(bar),None,List(),Left(Rft(App(NuNew(Var(A)),Tup(List((None,Fld(_,Var(foo)))))),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,Var(bar))), (None,Fld(_,IntLit(1)))))))), NuFunDef(None,Var(bar2),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,Var(newFun))), (None,Fld(_,IntLit(1)))))))))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class A$1([x,]) {fun foo = () => 0; fun bar = () => (this).x} @@ -436,8 +422,7 @@ new A{ } //│ |#class| |A| |{||}|↵|#new| |A|{|→|#fun| |foo| |#=| |1|↵|#fun| |bar| |#=| |#new| |A|{|→|#fun| |foo1| |#=| |foo|↵|#fun| |bar1| |#=| |#new| |A|{|→|#fun| |foo2| |#=| |foo|↵|#fun| |bar2| |#=| |#new| |A|{|→|#fun| |foo3| |#=| |foo|↵|#fun| |bar3| |#=| |#new| |A|{|→|#fun| |foo4| |#=| |foo|↵|#fun| |bar4| |#=| |0|←|↵|}|←|↵|}|←|↵|}|←|↵|}|←|↵|}| //│ Parsed: {class A {}; new A { ‹fun foo = 1; fun bar = new A { ‹fun foo1 = foo; fun bar1 = new A { ‹fun foo2 = foo; fun bar2 = new A { ‹fun foo3 = foo; fun bar3 = new A { ‹fun foo4 = foo; fun bar4 = 0› }› }› }› }› }} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List())), Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(IntLit(1))), NuFunDef(None,Var(bar),None,List(),Left(Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(foo1),None,List(),Left(Var(foo))), NuFunDef(None,Var(bar1),None,List(),Left(Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(foo2),None,List(),Left(Var(foo))), NuFunDef(None,Var(bar2),None,List(),Left(Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(foo3),None,List(),Left(Var(foo))), NuFunDef(None,Var(bar3),None,List(),Left(Rft(NuNew(Var(A)),TypingUnit(List(NuFunDef(None,Var(foo4),None,List(),Left(Var(foo))), NuFunDef(None,Var(bar4),None,List(),Left(IntLit(0)))))))))))))))))))))))))))) +//│ //│ Lifted: //│ TypingUnit {class A$1([]) {}; Code(List(new A$1([]) {}))} //│ diff --git a/compiler/shared/test/diff/LifterBlks.mls b/compiler/shared/test/diff/LifterBlks.mls index 826dc8a9c..9ea8e45f0 100644 --- a/compiler/shared/test/diff/LifterBlks.mls +++ b/compiler/shared/test/diff/LifterBlks.mls @@ -6,8 +6,7 @@ fun foo = print("ko") //│ |#fun| |foo| |#=|→|print|(|"ok"|)|↵|print|(|"ko"|)|←| //│ Parsed: {fun foo = {print("ok",); print("ko",)}} -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Blk(List(App(Var(print),Tup(List((None,Fld(_,StrLit(ok)))))), App(Var(print),Tup(List((None,Fld(_,StrLit(ko)))))))))))) +//│ //│ Lifted: //│ TypingUnit {fun foo$1 = () => {print("ok",); print("ko",)}} //│ @@ -18,8 +17,7 @@ class A{ } //│ |#class| |A|{|→|#class| |B| |{||}|↵|#fun| |foo|(|x|#:| |B|)| |#=| |(|x| |#:| |B|)|←|↵|}| //│ Parsed: {class A {class B {}; fun foo = (x: B,) => '(' x : B ')'}} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List())), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(_,Var(B))))),Bra(false,Asc(Var(x),TypeName(B))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1,]) {} @@ -40,8 +38,7 @@ fun foo = fun tmp = 2 //│ |#fun| |foo| |#=|→|#let| |local|(|x|)| |#=|→|#class| |Foo| |{|→|#fun| |bar| |#=| |x| |+| |1|←|↵|}|↵|Foo|(||)|.bar|←|↵|print| |#of| |local|(|0|)| |+| |local|(|1|)|↵|print| |#of| |(|local| |#of| |0|)| |+| |local| |#of| |1|↵|#fun| |tmp| |#=| |1|↵|print| |#of| |local| |#of| |0| |+| |local| |#of| |1|↵|#fun| |tmp| |#=| |2|←| //│ Parsed: {fun foo = {let local = (x,) => {class Foo {fun bar = +(x, 1,)}; (Foo()).bar}; print(+(local(0,), local(1,),),); print(+('(' local(0,) ')', local(1,),),); fun tmp = 1; print(local(+(0, local(1,),),),); fun tmp = 2}} -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Blk(List(NuFunDef(Some(false),Var(local),None,List(),Left(Lam(Tup(List((None,Fld(_,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(_,Var(x))), (None,Fld(_,IntLit(1))))))))))), Sel(App(Var(Foo),Tup(List())),Var(bar))))))), App(Var(print),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,App(Var(local),Tup(List((None,Fld(_,IntLit(0)))))))), (None,Fld(_,App(Var(local),Tup(List((None,Fld(_,IntLit(1)))))))))))))))), App(Var(print),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Bra(false,App(Var(local),Tup(List((None,Fld(_,IntLit(0))))))))), (None,Fld(_,App(Var(local),Tup(List((None,Fld(_,IntLit(1)))))))))))))))), NuFunDef(None,Var(tmp),None,List(),Left(IntLit(1))), App(Var(print),Tup(List((None,Fld(_,App(Var(local),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,IntLit(0))), (None,Fld(_,App(Var(local),Tup(List((None,Fld(_,IntLit(1))))))))))))))))))))), NuFunDef(None,Var(tmp),None,List(),Left(IntLit(2))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class Foo$1([x,]) {fun bar = () => +((this).x, 1,)} @@ -56,8 +53,7 @@ let f = x => new A(0){fun bar = x+y} f(0) //│ |#class| |A|(|y|)|{||}|↵|#let| |f| |#=| |x| |#=>| |#new| |A|(|0|)|{|#fun| |bar| |#=| |x|+|y|}|↵|f|(|0|)| //│ Parsed: {class A(y,) {}; let f = (x,) => (new A)(0,) { ‹fun bar = +(x, y,)› }; f(0,)} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(_,Var(y)))))),None,None,List(),None,None,TypingUnit(List())), NuFunDef(Some(false),Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Rft(App(NuNew(Var(A)),Tup(List((None,Fld(_,IntLit(0)))))),TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))))))))))), App(Var(f),Tup(List((None,Fld(_,IntLit(0)))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class A$1([y,]) {} @@ -79,8 +75,7 @@ class A(x){ } //│ |#class| |A|(|x|)|{|→|#fun| |w| |#=| |x|↵|#fun| |foo|(|y|)| |#=| |→|#class| |B|(|z|)|{|→|#fun| |bar| |#=| |x|+|y|+|z|←|↵|}|↵|#new| |B|(|0|)|{|→|#fun| |bar| |#=| |w|+|y|+|z|←|↵|}|←|←|↵|}| //│ Parsed: {class A(x,) {fun w = x; fun foo = (y,) => {class B(z,) {fun bar = +(+(x, y,), z,)}; (new B)(0,) { ‹fun bar = +(+(w, y,), z,)› }}}} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(_,Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(w),None,List(),Left(Var(x))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(y))))),Blk(List(NuTypeDef(Cls,TypeName(B),List(),Some(Tup(List((None,Fld(_,Var(z)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))))), (None,Fld(_,Var(z))))))))))), Rft(App(NuNew(Var(B)),Tup(List((None,Fld(_,IntLit(0)))))),TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(w))), (None,Fld(_,Var(y)))))))), (None,Fld(_,Var(z))))))))))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class A$1_B$2([par$A$1, z, y,]) { @@ -110,8 +105,7 @@ fun f(x,y,z) = } //│ |#fun| |f|(|x|,|y|,|z|)| |#=| |→|#class| |A|{|→|#fun| |foo| |#=| |#new| |B|↵|#fun| |bar1| |#=| |x|←|↵|}|↵|#class| |B|{|→|#fun| |foo| |#=| |#new| |A|↵|#fun| |bar2| |#=| |y|←|↵|}|↵|#class| |C| |#extends| |A|,| |B| |{|→|#fun| |bar| |#=| |bar1| |+| |bar2|←|↵|}|←| //│ Parsed: {fun f = (x, y, z,) => {class A {fun foo = new B; fun bar1 = x}; class B {fun foo = new A; fun bar2 = y}; class C: A, B {fun bar = +(bar1, bar2,)}}} -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y))), (None,Fld(_,Var(z))))),Blk(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(NuNew(Var(B)))), NuFunDef(None,Var(bar1),None,List(),Left(Var(x)))))), NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(NuNew(Var(A)))), NuFunDef(None,Var(bar2),None,List(),Left(Var(y)))))), NuTypeDef(Cls,TypeName(C),List(),None,None,None,List(Var(A), Var(B)),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,Var(bar1))), (None,Fld(_,Var(bar2)))))))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class A$1([x, y,]) { @@ -141,8 +135,7 @@ fun f(x,y,z) = } //│ |#fun| |f|(|x|,|y|,|z|)| |#=| |→|#class| |C|{|→|#class| |A|{|→|#fun| |foo| |#=| |#new| |B|↵|#fun| |bar1| |#=| |x|←|↵|}|↵|#class| |B|{|→|#fun| |foo| |#=| |#new| |A|↵|#fun| |bar2| |#=| |y|←|↵|}|↵|#fun| |boo| |#=| |(|#new| |A|)|.bar1| |+| |B|(||)|.bar2| |+| |z|←|↵|}|←| //│ Parsed: {fun f = (x, y, z,) => {class C {class A {fun foo = new B; fun bar1 = x}; class B {fun foo = new A; fun bar2 = y}; fun boo = +(+(('(' new A ')').bar1, (B()).bar2,), z,)}}} -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y))), (None,Fld(_,Var(z))))),Blk(List(NuTypeDef(Cls,TypeName(C),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(NuNew(Var(B)))), NuFunDef(None,Var(bar1),None,List(),Left(Var(x)))))), NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(NuNew(Var(A)))), NuFunDef(None,Var(bar2),None,List(),Left(Var(y)))))), NuFunDef(None,Var(boo),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Sel(Bra(false,NuNew(Var(A))),Var(bar1)))), (None,Fld(_,Sel(App(Var(B),Tup(List())),Var(bar2))))))))), (None,Fld(_,Var(z)))))))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class C$1_A$2([par$C$1,]) { @@ -167,8 +160,7 @@ fun f(y) = } //│ |#fun| |f|(|y|)| |#=|→|#let| |g|(|x|)| |#=| |x| |+| |y| |+| |1|↵|#class| |Foo|(|x|)| |{|→|#fun| |h| |#=| |g|(|x|)|←|↵|}|←| //│ Parsed: {fun f = (y,) => {let g = (x,) => +(+(x, y,), 1,); class Foo(x,) {fun h = g(x,)}}} -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(y))))),Blk(List(NuFunDef(Some(false),Var(g),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(+),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))))), (None,Fld(_,IntLit(1))))))))), NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((None,Fld(_,Var(x)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(h),None,List(),Left(App(Var(g),Tup(List((None,Fld(_,Var(x)))))))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class Foo$1([x, y,]) {fun h = () => g$2((this).x, y,)} @@ -179,16 +171,14 @@ fun f(y) = Foo(1).h //│ | |Foo|(|1|)|.h| //│ Parsed: {(Foo(1,)).h} -//│ Parsed: -//│ TypingUnit(List(Sel(App(Var(Foo),Tup(List((None,Fld(_,IntLit(1)))))),Var(h)))) +//│ //│ Lifted: //│ TypingUnit {Code(List((Foo(1,)).h))} //│ Foo(x).h //│ | |Foo|(|x|)|.h| //│ Parsed: {(Foo(x,)).h} -//│ Parsed: -//│ TypingUnit(List(Sel(App(Var(Foo),Tup(List((None,Fld(_,Var(x)))))),Var(h)))) +//│ //│ Lifted: //│ TypingUnit {Code(List((Foo(x,)).h))} //│ @@ -203,8 +193,7 @@ fun f(x) = Foo(x, x).bar //│ |#fun| |f|(|x|)| |#=|→|#let| |g|(|x|)| |#=| |→|#let| |h|(|x|)| |#=| |x| |+| |2|↵|Foo|(|h|(|x|)|,| |x|)|.bar|←|↵|#class| |Foo|(|x|,| |y|)| |{|→|#fun| |bar| |#=| |g|(|x|)|+|y|←|↵|}|↵|Foo|(|x|,| |x|)|.bar|←| //│ Parsed: {fun f = (x,) => {let g = (x,) => {let h = (x,) => +(x, 2,); (Foo(h(x,), x,)).bar}; class Foo(x, y,) {fun bar = +(g(x,), y,)}; (Foo(x, x,)).bar}} -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(NuFunDef(Some(false),Var(g),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(NuFunDef(Some(false),Var(h),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(2))))))))), Sel(App(Var(Foo),Tup(List((None,Fld(_,App(Var(h),Tup(List((None,Fld(_,Var(x)))))))), (None,Fld(_,Var(x)))))),Var(bar))))))), NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,App(Var(g),Tup(List((None,Fld(_,Var(x)))))))), (None,Fld(_,Var(y))))))))))), Sel(App(Var(Foo),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(x)))))),Var(bar))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class Foo$1([x, y,]) {fun bar = () => +(g$2((this).x,), (this).y,)} @@ -217,8 +206,7 @@ fun f(x) = class Foo(x, y) extends Bar(y, x), Baz(x + y) //│ |#class| |Foo|(|x|,| |y|)| |#extends| |Bar|(|y|,| |x|)|,| |Baz|(|x| |+| |y|)| //│ Parsed: {class Foo(x, y,): Bar(y, x,), Baz(+(x, y,),) {}} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))),None,None,List(App(Var(Bar),Tup(List((None,Fld(_,Var(y))), (None,Fld(_,Var(x)))))), App(Var(Baz),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y)))))))))))),None,None,TypingUnit(List())))) +//│ //│ Lifted: //│ TypingUnit { //│ class Foo$1([x, y,]): Bar((this).y, (this).x,), Baz(+((this).x, (this).y,),) {} @@ -232,8 +220,7 @@ fun foo(x: T): string = "rua" //│ |#fun| |foo|‹|T|,| |U|›|(|x|#:| |T|)|#:| |string| |#=| |→|#class| |A|(|y|)| |#extends| |B|‹|T|›|,| |C|(|y|#:| |U|)| |{|→|#fun| |bar| |#=| |this|←|↵|}|↵|"rua"|←| //│ Parsed: {fun foo = (x: T,) => {class A(y,): B‹T›, C(y: U,) {fun bar = this}; "rua"} : string} -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(TypeName(T), TypeName(U)),Left(Lam(Tup(List((Some(Var(x)),Fld(_,Var(T))))),Asc(Blk(List(NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((None,Fld(_,Var(y)))))),None,None,List(TyApp(Var(B),List(TypeName(T))), App(Var(C),Tup(List((Some(Var(y)),Fld(_,Var(U))))))),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(Var(this)))))), StrLit(rua))),TypeName(string))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class A$1[T,U]([y,]): B‹T›, C(y: U,) {fun bar = () => this} @@ -249,8 +236,7 @@ class A{ } //│ |#class| |A|‹|T|›|{|→|#class| |B|{|→|#fun| |f| |#=| |x| |#=>| |y| |#=>| |x|↵|#fun| |g|#:| |T| |#=>| |B| |#=>| |T|←|↵|}|←|↵|}| //│ Parsed: {class A‹T› {class B {fun f = (x,) => (y,) => x; fun g: T -> B -> T}}} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List((None,TypeName(T))),None,None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(B),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Lam(Tup(List((None,Fld(_,Var(y))))),Var(x))))), NuFunDef(None,Var(g),None,List(),Right(PolyType(List(),Function(Tuple(List((None,Field(None,TypeName(T))))),Function(Tuple(List((None,Field(None,TypeName(B))))),TypeName(T)))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class A$1_B$2_Lambda1$1$3([par$A$1_B$2, x,]) {fun apply = (y,) => (this).x} @@ -269,8 +255,7 @@ class Foo{ } //│ |#class| |Foo|‹|T|›|{|→|#class| |RectangleBox|#:| |Box|‹|T|›| |&| |{| |breadth|#:| |T| |}|↵|#class| |StackedRectangleBoxes|‹|N|›| |#:| |RectangleBox|‹|T|›| |&| |{| |size|#:| |N| |}|↵|#class| |Bar|#:| |{|any|#:| |RectangleBox| |#=>| |StackedRectangleBoxes|}|←|↵|}| //│ Parsed: {class Foo‹T› {class RectangleBox: Box[T] & {breadth: T} {}; class StackedRectangleBoxes‹N›: RectangleBox[T] & {size: N} {}; class Bar: {any: RectangleBox -> StackedRectangleBoxes} {}}} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Foo),List((None,TypeName(T))),None,None,None,List(),None,None,TypingUnit(List(NuTypeDef(Cls,TypeName(RectangleBox),List(),None,None,Some(Inter(AppliedType(TypeName(Box),List(TypeName(T))),Record(List((Var(breadth),Field(None,TypeName(T))))))),List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(StackedRectangleBoxes),List((None,TypeName(N))),None,None,Some(Inter(AppliedType(TypeName(RectangleBox),List(TypeName(T))),Record(List((Var(size),Field(None,TypeName(N))))))),List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(Bar),List(),None,None,Some(Record(List((Var(any),Field(None,Function(Tuple(List((None,Field(None,TypeName(RectangleBox))))),TypeName(StackedRectangleBoxes))))))),List(),None,None,TypingUnit(List()))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class Foo$1_RectangleBox$2([par$Foo$1,]) {} @@ -292,8 +277,7 @@ fun ctx(a,b) = }, b) //│ |#class| |Func|‹|T|,| |U|›| |{|→|#fun| |apply|#:| |T| |#=>| |U|←|↵|}|↵|#class| |Lambda|‹|T|,| |U|›| |#:| |Func|‹|T|,| |U|›| |{||}|↵|#fun| |ctx|(|a|,|b|)| |#=|→|#fun| |foo|(|f|#:| |Func|,| |x|)| |#=| |→|f|.apply|(|x|)|←|↵|foo|(|#new| |Lambda|{|→|#fun| |apply|(|x|)| |#=| |a|+|x|←|↵|}|,| |b|)|←| //│ Parsed: {class Func‹T, U› {fun apply: T -> U}; class Lambda‹T, U›: Func[T, U] {}; fun ctx = (a, b,) => {fun foo = (f: Func, x,) => {(f).apply(x,)}; foo(new Lambda { ‹fun apply = (x,) => +(a, x,)› }, b,)}} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Func),List((None,TypeName(T)), (None,TypeName(U))),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(apply),None,List(),Right(PolyType(List(),Function(Tuple(List((None,Field(None,TypeName(T))))),TypeName(U)))))))), NuTypeDef(Cls,TypeName(Lambda),List((None,TypeName(T)), (None,TypeName(U))),None,None,Some(AppliedType(TypeName(Func),List(TypeName(T), TypeName(U)))),List(),None,None,TypingUnit(List())), NuFunDef(None,Var(ctx),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(a))), (None,Fld(_,Var(b))))),Blk(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((Some(Var(f)),Fld(_,Var(Func))), (None,Fld(_,Var(x))))),Blk(List(App(Sel(Var(f),Var(apply)),Tup(List((None,Fld(_,Var(x))))))))))), App(Var(foo),Tup(List((None,Fld(_,Rft(NuNew(Var(Lambda)),TypingUnit(List(NuFunDef(None,Var(apply),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(+),Tup(List((None,Fld(_,Var(a))), (None,Fld(_,Var(x)))))))))))))), (None,Fld(_,Var(b))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class Func$1[T,U]([]) {fun apply = T -> U} @@ -308,8 +292,7 @@ fun f(T) = f(MyClass) //│ |#fun| |f|(|T|)| |#=| |→|#new| |T|(||)|←|↵|f|(|MyClass|)| //│ Parsed: {fun f = (T,) => {(new T)()}; f(MyClass,)} -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(T))))),Blk(List(App(NuNew(Var(T)),Tup(List()))))))), App(Var(f),Tup(List((None,Fld(_,Var(MyClass)))))))) +//│ //│ Lifted: //│ Lifting failed: mlscript.codegen.CodeGenError: Cannot find type T. Class values are not supported in lifter. //│ @@ -321,8 +304,7 @@ class A { } //│ |#class| |A| |{|→|#fun| |foo| |#=| |→|#fun| |bar| |#=| |foo|(||)|↵|bar|(||)|←|←|↵|}| //│ Parsed: {class A {fun foo = {fun bar = foo(); bar()}}} -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(A),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Blk(List(NuFunDef(None,Var(bar),None,List(),Left(App(Var(foo),Tup(List())))), App(Var(bar),Tup(List()))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class A$1([]) {fun foo = () => {bar$1(this,)}} diff --git a/compiler/shared/test/diff/mono.mls b/compiler/shared/test/diff/mono.mls index ef39b7e12..a261d75d0 100644 --- a/compiler/shared/test/diff/mono.mls +++ b/compiler/shared/test/diff/mono.mls @@ -3,8 +3,7 @@ :mono fun f(x: Int) = if x then 42 else 1337 -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(_,Var(Int))))),If(IfThen(Var(x),IntLit(42)),Some(IntLit(1337)))))))) +//│ //│ Lifted: //│ TypingUnit { //│ fun f$1 = (x: Int,) => if (x) then 42 else 1337 @@ -18,8 +17,7 @@ fun f(x: Int) = if x then 42 else 1337 :mono fun foo() = 42 -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List()),IntLit(42)))))) +//│ //│ Lifted: //│ TypingUnit {fun foo$1 = () => 42} //│ Mono: @@ -33,8 +31,7 @@ fun foo() = 42 fun foo(x, #b) = if b then x else 1337 let a = foo(42, true) let b = foo(23, false) -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))), (None,Fld(s,Var(b))))),If(IfThen(Var(b),Var(x)),Some(IntLit(1337)))))), NuFunDef(Some(false),Var(a),None,List(),Left(App(Var(foo),Tup(List((None,Fld(_,IntLit(42))), (None,Fld(_,Var(true)))))))), NuFunDef(Some(false),Var(b),None,List(),Left(App(Var(foo),Tup(List((None,Fld(_,IntLit(23))), (None,Fld(_,Var(false)))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ fun foo$3 = (x, #b,) => if (b) then x else 1337 @@ -60,8 +57,7 @@ let b = foo(23, false) :mono let x = 42 + 1337 -//│ Parsed: -//│ TypingUnit(List(NuFunDef(Some(false),Var(x),None,List(),Left(App(Var(+),Tup(List((None,Fld(_,IntLit(42))), (None,Fld(_,IntLit(1337)))))))))) +//│ //│ Lifted: //│ TypingUnit {let x$1 = () => +(42, 1337,)} //│ Mono: @@ -98,8 +94,7 @@ let x = 42 + 1337 :mono if true then 1 else 0 if 1+1 > 1 then 1 - 1 else 1*1 -//│ Parsed: -//│ TypingUnit(List(If(IfThen(Var(true),IntLit(1)),Some(IntLit(0))), If(IfThen(App(Var(>),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,IntLit(1)))))))), (None,Fld(_,IntLit(1)))))),App(Var(-),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,IntLit(1))))))),Some(App(Var(*),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,IntLit(1)))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ Code(List(if (true) then 1 else 0)) @@ -122,8 +117,7 @@ if 1+1 > 1 then 1 - 1 else 1*1 :mono if(b) then 1 else 2 -//│ Parsed: -//│ TypingUnit(List(If(IfThen(Bra(false,Var(b)),IntLit(1)),Some(IntLit(2))))) +//│ //│ Lifted: //│ TypingUnit {Code(List(if ('(' b ')') then 1 else 2))} //│ Mono: @@ -138,8 +132,7 @@ if(b) then 1 else 2 :mono ((f, g) => f(g))(f => f, true) -//│ Parsed: -//│ TypingUnit(List(App(Bra(false,Lam(Tup(List((None,Fld(_,Var(f))), (None,Fld(_,Var(g))))),App(Var(f),Tup(List((None,Fld(_,Var(g)))))))),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(f))))),Var(f)))), (None,Fld(_,Var(true)))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class Lambda2$1$1([]) {fun apply = (f, g,) => f(g,)} @@ -167,8 +160,7 @@ if(b) then 1 else 2 :mono (b => if b then true else false) (true) -//│ Parsed: -//│ TypingUnit(List(App(Bra(false,Lam(Tup(List((None,Fld(_,Var(b))))),If(IfThen(Var(b),Var(true)),Some(Var(false))))),Tup(List((None,Fld(_,Var(true)))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class Lambda1$1$1([]) {fun apply = (b,) => if (b) then true else false} @@ -192,8 +184,7 @@ if(b) then 1 else 2 fun f(x) = if(x > 0) then x+1 else x - 1 f(2)+3 -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(If(IfThen(Bra(false,App(Var(>),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(0))))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1))))))),Some(App(Var(-),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1))))))))))))), App(Var(+),Tup(List((None,Fld(_,App(Var(f),Tup(List((None,Fld(_,IntLit(2)))))))), (None,Fld(_,IntLit(3)))))))) +//│ //│ Lifted: //│ TypingUnit { //│ fun f$1 = (x,) => {if ('(' >(x, 0,) ')') then +(x, 1,) else -(x, 1,)} @@ -216,8 +207,7 @@ f(2)+3 fun fac(n) = if (n > 1) then fac(n - 1) * n else 1 fac(2) -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(fac),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(n))))),Blk(List(If(IfThen(Bra(false,App(Var(>),Tup(List((None,Fld(_,Var(n))), (None,Fld(_,IntLit(1))))))),App(Var(*),Tup(List((None,Fld(_,App(Var(fac),Tup(List((None,Fld(_,App(Var(-),Tup(List((None,Fld(_,Var(n))), (None,Fld(_,IntLit(1))))))))))))), (None,Fld(_,Var(n))))))),Some(IntLit(1)))))))), App(Var(fac),Tup(List((None,Fld(_,IntLit(2)))))))) +//│ //│ Lifted: //│ TypingUnit { //│ fun fac$1 = (n,) => {if ('(' >(n, 1,) ')') then *(fac$1(-(n, 1,),), n,) else 1} @@ -245,8 +235,7 @@ fun count(lst) = if l is undefined then 1 else count(l)+1 else 0 count(new List(new List(new Nil(undefined, false), true), true)) -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(List),List(),Some(Tup(List((Some(Var(l)),Fld(g,App(Var(|),Tup(List((None,Fld(_,App(Var(|),Tup(List((None,Fld(_,Var(List))), (None,Fld(_,Var(Nil)))))))), (None,Fld(_,UnitLit(true)))))))), (Some(Var(hasTail)),Fld(g,Var(Bool)))))),None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List((Some(Var(l)),Fld(g,App(Var(|),Tup(List((None,Fld(_,App(Var(|),Tup(List((None,Fld(_,Var(List))), (None,Fld(_,Var(Nil)))))))), (None,Fld(_,UnitLit(true)))))))), (Some(Var(hasTail)),Fld(g,Var(Bool)))))),None,None,List(),None,None,TypingUnit(List())), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(lst))))),Blk(List(If(IfThen(Sel(Var(lst),Var(hasTail)),Blk(List(NuFunDef(Some(false),Var(l),None,List(),Left(Sel(Var(lst),Var(l)))), If(IfThen(App(Var(is),Tup(List((None,Fld(_,Var(l))), (None,Fld(_,UnitLit(true)))))),IntLit(1)),Some(App(Var(+),Tup(List((None,Fld(_,App(Var(count),Tup(List((None,Fld(_,Var(l)))))))), (None,Fld(_,IntLit(1))))))))))),Some(IntLit(0)))))))), App(Var(count),Tup(List((None,Fld(_,App(NuNew(Var(List)),Tup(List((None,Fld(_,App(NuNew(Var(List)),Tup(List((None,Fld(_,App(NuNew(Var(Nil)),Tup(List((None,Fld(_,UnitLit(true))), (None,Fld(_,Var(false)))))))), (None,Fld(_,Var(true)))))))), (None,Fld(_,Var(true))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class List$1([val l: |(|(List, Nil,), undefined,), val hasTail: Bool,]) {} @@ -302,8 +291,7 @@ class Nil() { } fun add2(x) = x+2 (new List(1, new List(2, new Nil()))).map(x => x+1).map(x => add2(x)) -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(List),List(),Some(Tup(List((Some(Var(e)),Fld(_,Var(Int))), (Some(Var(tail)),Fld(_,App(Var(|),Tup(List((None,Fld(_,Var(List))), (None,Fld(_,Var(Nil))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(map),None,List(),Right(PolyType(List(),Function(Tuple(List((None,Field(None,Function(Tuple(List((None,Field(None,TypeName(Int))))),TypeName(Int)))))),TypeName(List))))), NuFunDef(None,Var(map),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(f))))),App(NuNew(Var(List)),Tup(List((None,Fld(_,App(Var(f),Tup(List((None,Fld(_,Var(e)))))))), (None,Fld(_,App(Sel(Var(tail),Var(map)),Tup(List((None,Fld(_,Var(f)))))))))))))), NuFunDef(None,Var(count),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(Sel(Var(tail),Var(count)),Tup(List()))))))))))))), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(map),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(f))))),Var(this)))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),IntLit(0))))))), NuFunDef(None,Var(add2),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(2))))))))), App(Sel(App(Sel(Bra(false,App(NuNew(Var(List)),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(NuNew(Var(List)),Tup(List((None,Fld(_,IntLit(2))), (None,Fld(_,App(NuNew(Var(Nil)),Tup(List()))))))))))))),Var(map)),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1)))))))))))),Var(map)),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(add2),Tup(List((None,Fld(_,Var(x)))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class List$1([e: Int, tail: |(List, Nil,),]) { @@ -369,8 +357,7 @@ fun generate(x) = if x > 0 then new List(x, generate(x+1)) else new Nil() foo(new List(1, new List(2, new Nil()))) foo(generate(1)) -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(List),List(),Some(Tup(List((Some(Var(e)),Fld(_,Var(Int))), (Some(Var(tail)),Fld(_,App(Var(|),Tup(List((None,Fld(_,Var(List))), (None,Fld(_,Var(Nil))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(Sel(Var(tail),Var(count)),Tup(List()))))))))))))), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),IntLit(0))))))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),App(Sel(Var(x),Var(count)),Tup(List()))))), NuFunDef(None,Var(generate),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(If(IfThen(App(Var(>),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(0)))))),App(NuNew(Var(List)),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,App(Var(generate),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1))))))))))))))))),Some(App(NuNew(Var(Nil)),Tup(List()))))))))), App(Var(foo),Tup(List((None,Fld(_,App(NuNew(Var(List)),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(NuNew(Var(List)),Tup(List((None,Fld(_,IntLit(2))), (None,Fld(_,App(NuNew(Var(Nil)),Tup(List()))))))))))))))))), App(Var(foo),Tup(List((None,Fld(_,App(Var(generate),Tup(List((None,Fld(_,IntLit(1))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class List$1([e: Int, tail: |(List, Nil,),]) { @@ -423,8 +410,7 @@ foo(generate(1)) fun foo(x) = (f => f(x))(z => z+1) foo(2) -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(App(Bra(false,Lam(Tup(List((None,Fld(_,Var(f))))),App(Var(f),Tup(List((None,Fld(_,Var(x)))))))),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(z))))),App(Var(+),Tup(List((None,Fld(_,Var(z))), (None,Fld(_,IntLit(1))))))))))))))))), App(Var(foo),Tup(List((None,Fld(_,IntLit(2)))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class Lambda1$2$1([x,]) {fun apply = (f,) => f((this).x,)} @@ -457,8 +443,7 @@ foo(2) fun f(x) = (y => f(x+y))(x+1) f(1) -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(App(Bra(false,Lam(Tup(List((None,Fld(_,Var(y))))),App(Var(f),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y))))))))))))),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1)))))))))))))))), App(Var(f),Tup(List((None,Fld(_,IntLit(1)))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class Lambda1$2$1([x,]) {fun apply = (y,) => f$1(+((this).x, y,),)} @@ -488,8 +473,7 @@ f(1) fun f(x) = f(x) f(0) f(1) -//│ Parsed: -//│ TypingUnit(List(NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(f),Tup(List((None,Fld(_,Var(x))))))))), App(Var(f),Tup(List((None,Fld(_,IntLit(0)))))), App(Var(f),Tup(List((None,Fld(_,IntLit(1)))))))) +//│ //│ Lifted: //│ TypingUnit { //│ fun f$1 = (x,) => f$1(x,) @@ -536,8 +520,7 @@ fun foo(x) = x.apply(new Cons(1, new Nil())) + x.apply(new Nil()) foo(new Lambda()) foo(new Lambda2(2)) -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Cons),List(),Some(Tup(List((Some(Var(e)),Fld(_,Var('A))), (Some(Var(tail)),Fld(_,App(Var(|),Tup(List((None,Fld(_,Var(Cons))), (None,Fld(_,Var(Nil))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(Sel(Var(tail),Var(count)),Tup(List()))))))))))))), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),IntLit(0))))))), NuTypeDef(Cls,TypeName(Lambda),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(apply),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(l))))),Blk(List(App(Sel(Var(l),Var(count)),Tup(List())))))))))), NuTypeDef(Cls,TypeName(Lambda2),List(),Some(Tup(List((Some(Var(a)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(apply),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(l))))),Blk(List(App(Sel(Bra(false,App(NuNew(Var(Cons)),Tup(List((None,Fld(_,Var(a))), (None,Fld(_,Var(l))))))),Var(count)),Tup(List())))))))))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(App(Var(+),Tup(List((None,Fld(_,App(Sel(Var(x),Var(apply)),Tup(List((None,Fld(_,App(NuNew(Var(Cons)),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(NuNew(Var(Nil)),Tup(List())))))))))))))), (None,Fld(_,App(Sel(Var(x),Var(apply)),Tup(List((None,Fld(_,App(NuNew(Var(Nil)),Tup(List()))))))))))))))))), App(Var(foo),Tup(List((None,Fld(_,App(NuNew(Var(Lambda)),Tup(List()))))))), App(Var(foo),Tup(List((None,Fld(_,App(NuNew(Var(Lambda2)),Tup(List((None,Fld(_,IntLit(2))))))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class Cons$1([e: 'A, tail: |(Cons, Nil,),]) { @@ -611,8 +594,7 @@ fun foo(x) = x(new Cons(1, new Nil())) + x(new Nil()) foo(l => l.count()) foo(l => (new Cons(2, l)).count()) -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Cons),List(),Some(Tup(List((Some(Var(e)),Fld(_,Var(Int))), (Some(Var(tail)),Fld(_,App(Var(|),Tup(List((None,Fld(_,Var(Cons))), (None,Fld(_,Var(Nil))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(Sel(Var(tail),Var(count)),Tup(List()))))))))))))), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(count),None,List(),Left(Lam(Tup(List()),IntLit(0))))))), NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(App(Var(+),Tup(List((None,Fld(_,App(Var(x),Tup(List((None,Fld(_,App(NuNew(Var(Cons)),Tup(List((None,Fld(_,IntLit(1))), (None,Fld(_,App(NuNew(Var(Nil)),Tup(List())))))))))))))), (None,Fld(_,App(Var(x),Tup(List((None,Fld(_,App(NuNew(Var(Nil)),Tup(List()))))))))))))))))), App(Var(foo),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(l))))),App(Sel(Var(l),Var(count)),Tup(List())))))))), App(Var(foo),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(l))))),App(Sel(Bra(false,App(NuNew(Var(Cons)),Tup(List((None,Fld(_,IntLit(2))), (None,Fld(_,Var(l))))))),Var(count)),Tup(List())))))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class Cons$1([e: Int, tail: |(Cons, Nil,),]) { @@ -706,8 +688,7 @@ class C(e1: Exp, e2: Exp) extends Exp { e1.isEmpty() && e2.isEmpty() } (new C(new Ch(1), new A(new Ch(2), new Ch(3)))).derive(0).isEmpty() -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Exp),List(),Some(Tup(List())),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Right(PolyType(List(),Function(Tuple(List((Some(Var(x)),Field(None,TypeName(Int))))),TypeName(Exp))))), NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((Some(Var(x)),Fld(_,Var(Int))))),App(Var(Exp),Tup(List()))))), NuFunDef(None,Var(isEmpty),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Bool))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Var(false))))))), NuTypeDef(Cls,TypeName(E),List(),Some(Tup(List())),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(NuNew(Var(E))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(Var(false))))))))), NuTypeDef(Cls,TypeName(Ep),List(),Some(Tup(List())),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(NuNew(Var(E))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(Var(true))))))))), NuTypeDef(Cls,TypeName(Ch),List(),Some(Tup(List((Some(Var(i)),Fld(_,Var(Int)))))),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(If(IfThen(App(Var(==),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(i)))))),NuNew(Var(Ep))),Some(NuNew(Var(E))))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(Var(false))))))))), NuTypeDef(Cls,TypeName(A),List(),Some(Tup(List((Some(Var(e1)),Fld(_,Var(Exp))), (Some(Var(e2)),Fld(_,Var(Exp)))))),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(App(NuNew(Var(A)),Tup(List((None,Fld(_,App(Sel(Var(e1),Var(derive)),Tup(List((None,Fld(_,Var(x)))))))), (None,Fld(_,App(Sel(Var(e2),Var(derive)),Tup(List((None,Fld(_,Var(x)))))))))))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(App(Var(||),Tup(List((None,Fld(_,App(Sel(Var(e1),Var(isEmpty)),Tup(List())))), (None,Fld(_,App(Sel(Var(e2),Var(isEmpty)),Tup(List()))))))))))))))), NuTypeDef(Cls,TypeName(C),List(),Some(Tup(List((Some(Var(e1)),Fld(_,Var(Exp))), (Some(Var(e2)),Fld(_,Var(Exp)))))),None,None,List(Var(Exp)),None,None,TypingUnit(List(NuFunDef(None,Var(derive),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(If(IfThen(App(Sel(Var(e1),Var(isEmpty)),Tup(List())),App(NuNew(Var(A)),Tup(List((None,Fld(_,App(NuNew(Var(C)),Tup(List((None,Fld(_,App(Sel(Var(e1),Var(derive)),Tup(List((None,Fld(_,Var(x)))))))), (None,Fld(_,Var(e2)))))))), (None,Fld(_,App(Sel(Var(e2),Var(derive)),Tup(List((None,Fld(_,Var(x)))))))))))),Some(App(NuNew(Var(C)),Tup(List((None,Fld(_,App(Sel(Var(e1),Var(derive)),Tup(List((None,Fld(_,Var(x)))))))), (None,Fld(_,Var(e2))))))))))))), NuFunDef(None,Var(isEmpty),None,List(),Left(Lam(Tup(List()),Blk(List(App(Var(&&),Tup(List((None,Fld(_,App(Sel(Var(e1),Var(isEmpty)),Tup(List())))), (None,Fld(_,App(Sel(Var(e2),Var(isEmpty)),Tup(List()))))))))))))))), App(Sel(App(Sel(Bra(false,App(NuNew(Var(C)),Tup(List((None,Fld(_,App(NuNew(Var(Ch)),Tup(List((None,Fld(_,IntLit(1)))))))), (None,Fld(_,App(NuNew(Var(A)),Tup(List((None,Fld(_,App(NuNew(Var(Ch)),Tup(List((None,Fld(_,IntLit(2)))))))), (None,Fld(_,App(NuNew(Var(Ch)),Tup(List((None,Fld(_,IntLit(3))))))))))))))))),Var(derive)),Tup(List((None,Fld(_,IntLit(0)))))),Var(isEmpty)),Tup(List())))) +//│ //│ Lifted: //│ TypingUnit { //│ class Exp$1([]) { @@ -808,8 +789,7 @@ class Nil(hasTail: Bool) {} fun gen() = if anyUnknown then new List(gen(), true) else new Nil(false) gen() -//│ Parsed: -//│ TypingUnit(List(NuFunDef(Some(false),Var(anyUnknown),None,List(),Left(Var(false))), NuTypeDef(Cls,TypeName(List),List(),Some(Tup(List((Some(Var(l)),Fld(_,App(Var(|),Tup(List((None,Fld(_,Var(List))), (None,Fld(_,Var(Nil)))))))), (Some(Var(hasTail)),Fld(_,Var(Bool)))))),None,None,List(),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(Nil),List(),Some(Tup(List((Some(Var(hasTail)),Fld(_,Var(Bool)))))),None,None,List(),None,None,TypingUnit(List())), NuFunDef(None,Var(gen),None,List(),Left(Lam(Tup(List()),Blk(List(If(IfThen(Var(anyUnknown),App(NuNew(Var(List)),Tup(List((None,Fld(_,App(Var(gen),Tup(List())))), (None,Fld(_,Var(true))))))),Some(App(NuNew(Var(Nil)),Tup(List((None,Fld(_,Var(false))))))))))))), App(Var(gen),Tup(List())))) +//│ //│ Lifted: //│ TypingUnit { //│ class List$1([l: |(List, Nil,), hasTail: Bool,]) {} @@ -850,8 +830,7 @@ class Foo(x: Int){ fun boo(z) = bar(z)+x } (new Foo(1)).boo(2) -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((Some(Var(x)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(bar),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(y))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y))))))))), NuFunDef(None,Var(boo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(z))))),App(Var(+),Tup(List((None,Fld(_,App(Var(bar),Tup(List((None,Fld(_,Var(z)))))))), (None,Fld(_,Var(x)))))))))))), App(Sel(Bra(false,App(NuNew(Var(Foo)),Tup(List((None,Fld(_,IntLit(1))))))),Var(boo)),Tup(List((None,Fld(_,IntLit(2)))))))) +//│ //│ Lifted: //│ TypingUnit { //│ class Foo$1([x: Int,]) { @@ -887,8 +866,7 @@ class OneInt(a: Int){ if(a > 0) then (new OneInt(a - 1)).fac() else 1 } (new OneInt(10)).fac() -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(OneInt),List(),Some(Tup(List((Some(Var(a)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(fac),None,List(),Right(PolyType(List(),Function(Tuple(List()),TypeName(Int))))), NuFunDef(None,Var(fac),None,List(),Left(Lam(Tup(List()),Blk(List(If(IfThen(Bra(false,App(Var(>),Tup(List((None,Fld(_,Var(a))), (None,Fld(_,IntLit(0))))))),App(Sel(Bra(false,App(NuNew(Var(OneInt)),Tup(List((None,Fld(_,App(Var(-),Tup(List((None,Fld(_,Var(a))), (None,Fld(_,IntLit(1)))))))))))),Var(fac)),Tup(List()))),Some(IntLit(1))))))))))), App(Sel(Bra(false,App(NuNew(Var(OneInt)),Tup(List((None,Fld(_,IntLit(10))))))),Var(fac)),Tup(List())))) +//│ //│ Lifted: //│ TypingUnit { //│ class OneInt$1([a: Int,]) { @@ -937,8 +915,7 @@ fun g(x) = if x > any then g(x - 1) else f(x - 2) g(1) -//│ Parsed: -//│ TypingUnit(List(NuFunDef(Some(false),Var(any),None,List(),Left(IntLit(-20))), NuFunDef(None,Var(f),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(If(IfThen(App(Var(>),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(any)))))),IntLit(0)),Some(App(Var(g),Tup(List((None,Fld(_,App(Var(-),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1)))))))))))))))))), NuFunDef(None,Var(g),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Blk(List(If(IfThen(App(Var(>),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(any)))))),App(Var(g),Tup(List((None,Fld(_,App(Var(-),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1)))))))))))),Some(App(Var(f),Tup(List((None,Fld(_,App(Var(-),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(2)))))))))))))))))), App(Var(g),Tup(List((None,Fld(_,IntLit(1)))))))) +//│ //│ Lifted: //│ TypingUnit { //│ let any$3 = () => -20 @@ -976,8 +953,7 @@ class OneBool(b: Bool){ fun get = () -> b } (if b then new OneInt(1) else new OneBool(true)).get() -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(OneInt),List(),Some(Tup(List((Some(Var(a)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(get),None,List(),Left(Lam(Tup(List()),Var(a))))))), NuTypeDef(Cls,TypeName(OneBool),List(),Some(Tup(List((Some(Var(b)),Fld(_,Var(Bool)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(get),None,List(),Left(Lam(Tup(List()),Var(b))))))), App(Sel(Bra(false,If(IfThen(Var(b),App(NuNew(Var(OneInt)),Tup(List((None,Fld(_,IntLit(1))))))),Some(App(NuNew(Var(OneBool)),Tup(List((None,Fld(_,Var(true))))))))),Var(get)),Tup(List())))) +//│ //│ Lifted: //│ TypingUnit { //│ class OneInt$1([a: Int,]) {fun get = () => (this).a} @@ -1022,8 +998,7 @@ let bar = Bar(42) baz(bar) (new Car()).da(Bar(1337)) bar.car -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Bar),List(),Some(Tup(List((Some(Var(x)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List((None,Fld(_,Var(x))))),Var(x)))), NuFunDef(None,Var(FooMinus),None,List(),Left(Lam(Tup(List((Some(Var(y)),Fld(_,Var(Int))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,Var(y))))))))), NuFunDef(None,Var(car),None,List(),Left(App(Var(foo),Tup(List((None,Fld(_,IntLit(2))))))))))), NuTypeDef(Cls,TypeName(Car),List(),None,None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(da),None,List(),Left(Lam(Tup(List((Some(Var(b)),Fld(_,Var(Bar))))),App(Sel(Var(b),Var(foo)),Tup(List((None,Fld(_,IntLit(2)))))))))))), NuFunDef(None,Var(baz),None,List(),Left(Lam(Tup(List((Some(Var(b)),Fld(_,Var(Bar))))),App(Sel(Var(b),Var(foo)),Tup(List((None,Fld(_,IntLit(2))))))))), NuFunDef(Some(false),Var(bar),None,List(),Left(App(Var(Bar),Tup(List((None,Fld(_,IntLit(42)))))))), App(Var(baz),Tup(List((None,Fld(_,Var(bar)))))), App(Sel(Bra(false,App(NuNew(Var(Car)),Tup(List()))),Var(da)),Tup(List((None,Fld(_,App(Var(Bar),Tup(List((None,Fld(_,IntLit(1337))))))))))), Sel(Var(bar),Var(car)))) +//│ //│ Lifted: //│ TypingUnit { //│ class Bar$1([x: Int,]) { @@ -1093,8 +1068,7 @@ class Sub2(c: Int) extends Sub(c+c){ } (new Sub(10)).foo() (new Sub2(c)).foo() -//│ Parsed: -//│ TypingUnit(List(NuFunDef(Some(false),Var(c),None,List(),Left(IntLit(5))), NuTypeDef(Cls,TypeName(Sup),List(),Some(Tup(List((Some(Var(a)),Fld(_,Var(Int)))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List()),Var(a))))))), NuTypeDef(Cls,TypeName(Sub),List(),Some(Tup(List((Some(Var(b)),Fld(_,Var(Int)))))),None,None,List(App(Var(Sup),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(b))), (None,Fld(_,Var(b)))))))))))),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(Sub2),List(),Some(Tup(List((Some(Var(c)),Fld(_,Var(Int)))))),None,None,List(App(Var(Sub),Tup(List((None,Fld(_,App(Var(+),Tup(List((None,Fld(_,Var(c))), (None,Fld(_,Var(c)))))))))))),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List()),App(Var(+),Tup(List((None,Fld(_,Var(a))), (None,Fld(_,Var(c)))))))))))), App(Sel(Bra(false,App(NuNew(Var(Sub)),Tup(List((None,Fld(_,IntLit(10))))))),Var(foo)),Tup(List())), App(Sel(Bra(false,App(NuNew(Var(Sub2)),Tup(List((None,Fld(_,Var(c))))))),Var(foo)),Tup(List())))) +//│ //│ Lifted: //│ TypingUnit { //│ class Sup$1([a: Int,]) {fun foo = () => (this).a} @@ -1151,8 +1125,7 @@ class F1() extends Foo(x => x+1){} class F2() extends Foo(x => x+2){} (new F1()).foo() (new F2()).foo() -//│ Parsed: -//│ TypingUnit(List(NuTypeDef(Cls,TypeName(Foo),List(),Some(Tup(List((Some(Var(f)),Fld(_,App(Var(->),Tup(List((None,Fld(_,Var(Int))), (None,Fld(_,Var(Int))))))))))),None,None,List(),None,None,TypingUnit(List(NuFunDef(None,Var(foo),None,List(),Left(Lam(Tup(List()),App(Var(f),Tup(List((None,Fld(_,IntLit(1)))))))))))), NuTypeDef(Cls,TypeName(F1),List(),Some(Tup(List())),None,None,List(App(Var(Foo),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(1))))))))))))),None,None,TypingUnit(List())), NuTypeDef(Cls,TypeName(F2),List(),Some(Tup(List())),None,None,List(App(Var(Foo),Tup(List((None,Fld(_,Lam(Tup(List((None,Fld(_,Var(x))))),App(Var(+),Tup(List((None,Fld(_,Var(x))), (None,Fld(_,IntLit(2))))))))))))),None,None,TypingUnit(List())), App(Sel(Bra(false,App(NuNew(Var(F1)),Tup(List()))),Var(foo)),Tup(List())), App(Sel(Bra(false,App(NuNew(Var(F2)),Tup(List()))),Var(foo)),Tup(List())))) +//│ //│ Lifted: //│ TypingUnit { //│ class Foo$1([f: ->(Int, Int,),]) {fun foo = () => (this).f(1,)} diff --git a/compiler/shared/test/scala/mlscript/compiler/Test.scala b/compiler/shared/test/scala/mlscript/compiler/Test.scala index a93ca5089..7f4c81698 100644 --- a/compiler/shared/test/scala/mlscript/compiler/Test.scala +++ b/compiler/shared/test/scala/mlscript/compiler/Test.scala @@ -13,8 +13,6 @@ class DiffTestCompiler extends DiffTests { import DiffTestCompiler.* override def postProcess(mode: ModeType, basePath: List[Str], testName: Str, unit: TypingUnit): List[Str] = val outputBuilder = StringBuilder() - outputBuilder ++= "Parsed:\n" - outputBuilder ++= unit.toString outputBuilder ++= "\nLifted:\n" var rstUnit = unit; From 16187c29783c10e92eaa960811c0fbfe8a2a9f87 Mon Sep 17 00:00:00 2001 From: Luyu Cheng Date: Mon, 1 Jan 2024 23:12:19 +0800 Subject: [PATCH 09/11] Remove impudent `???` in `StatementImpl`'s `showDbg` --- shared/src/main/scala/mlscript/helpers.scala | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/shared/src/main/scala/mlscript/helpers.scala b/shared/src/main/scala/mlscript/helpers.scala index 57b2a5aea..f8d6ecd24 100644 --- a/shared/src/main/scala/mlscript/helpers.scala +++ b/shared/src/main/scala/mlscript/helpers.scala @@ -409,8 +409,6 @@ trait DeclImpl extends Located { self: Decl => case _: Def => "definition" case _: TypeDef => "type declaration" } - override def showDbg: Str = showHead + (this match { - case TypeDef(Als, _, _, _, _, _, _, _) => " = "; case _ => ": " }) + showBody def showHead: Str = this match { case Def(true, n, b, isByname) => s"rec def ${n.showDbg}" case Def(false, n, b, isByname) => s"def ${n.showDbg}" @@ -442,11 +440,6 @@ trait NuDeclImpl extends Located { self: NuDecl => case _: NuFunDef => "definition" case _: NuTypeDef => "type declaration" } - override def showDbg: Str = showHead + (this match { - case NuFunDef(_, _, _, _, L(_)) => " = " - case NuFunDef(_, _, _, _, R(_)) => ": " - case _: NuTypeDef => " " - }) + showBody def showHead: Str = this match { case NuFunDef(N, n, snme, _, b) => s"fun${snme.fold("")(" ("+_.name+")")} ${n.name}" case NuFunDef(S(false), n, snme, _, b) => s"let${snme.fold("")(" "+_.name+")")} ${n.name}" @@ -494,7 +487,6 @@ trait ConstructorImpl { self: Constructor => // def children: List[Located] = fields.map(_._2) def describe: Str = "constructor" // def showDbg: Str = s"constructor(${fields.map(_._1.name).mkString(", ")})" - override def showDbg: Str = s"constructor(${this.params.showElems}) ${this.body.showDbg}" } trait TypeNameImpl extends Ordered[TypeName] { self: TypeName => @@ -1024,7 +1016,17 @@ trait StatementImpl extends Located { self: Statement => case LetS(isRec, name, rhs) => s"let${if (isRec) " rec" else ""} ${name.showDbg} = ${rhs.showDbg}" case DatatypeDefn(head, body) => s"data type ${head.showDbg} of ${body.showDbg}" case DataDefn(head) => s"data ${head.showDbg}" - case _: Constructor | _: Term | _: Decl | _: NuDecl => ??? // Implemented in subclasses + case Constructor(params, body) => s"constructor(${params.showElems}) ${body.showDbg}" + case t: Term => t.print(false) + case d: Decl => d.showHead + (d match { + case TypeDef(Als, _, _, _, _, _, _, _) => " = "; + case _ => ": " + }) + d.showBody + case n: NuDecl => n.showHead + (n match { + case NuFunDef(_, _, _, _, L(_)) => " = " + case NuFunDef(_, _, _, _, R(_)) => ": " + case _: NuTypeDef => " " + }) + n.showBody } } From 1665c8db9740058166552780e121477161df62e5 Mon Sep 17 00:00:00 2001 From: Luyu Cheng Date: Tue, 2 Jan 2024 04:14:18 +0800 Subject: [PATCH 10/11] Remove some reckless and arbitrary uses of wildcards --- shared/src/main/scala/mlscript/helpers.scala | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/shared/src/main/scala/mlscript/helpers.scala b/shared/src/main/scala/mlscript/helpers.scala index f8d6ecd24..8dfd7c02e 100644 --- a/shared/src/main/scala/mlscript/helpers.scala +++ b/shared/src/main/scala/mlscript/helpers.scala @@ -402,7 +402,7 @@ object OpApp { trait DeclImpl extends Located { self: Decl => val body: Located def showBody: Str = this match { - case Def(_, _, rhs, isByname) => rhs.fold(_.showDbg, _.showDbg2) + case d: Def => d.rhs.fold(_.showDbg, _.showDbg2) case td: TypeDef => td.body.showDbg2 } def describe: Str = this match { @@ -433,7 +433,7 @@ trait NuDeclImpl extends Located { self: NuDecl => } def name: Str = nameVar.name def showBody: Str = this match { - case NuFunDef(_, _, _, _, rhs) => rhs.fold(_.print(false), _.showDbg2) + case fd: NuFunDef => fd.rhs.fold(_.print(false), _.showDbg2) case td: NuTypeDef => td.body.showDbgTop } def describe: Str = this match { @@ -1019,12 +1019,11 @@ trait StatementImpl extends Located { self: Statement => case Constructor(params, body) => s"constructor(${params.showElems}) ${body.showDbg}" case t: Term => t.print(false) case d: Decl => d.showHead + (d match { - case TypeDef(Als, _, _, _, _, _, _, _) => " = "; + case n: TypeDef if n.kind is Als => " = " case _ => ": " }) + d.showBody case n: NuDecl => n.showHead + (n match { - case NuFunDef(_, _, _, _, L(_)) => " = " - case NuFunDef(_, _, _, _, R(_)) => ": " + case n: NuFunDef => if (n.rhs.isLeft) " = " else ": " case _: NuTypeDef => " " }) + n.showBody } From fb7fc3542aaf3fc5e5b78e3fc33260a0a6107059 Mon Sep 17 00:00:00 2001 From: Luyu Cheng Date: Tue, 2 Jan 2024 14:29:55 +0800 Subject: [PATCH 11/11] Remove `showDbgTop` --- compiler/shared/test/diff/Lifter.mls | 18 +++++++++--------- compiler/shared/test/diff/LifterBlks.mls | 6 +++--- shared/src/main/scala/mlscript/helpers.scala | 15 ++++----------- shared/src/test/diff/parser/BasicSyntax.mls | 6 +++--- shared/src/test/diff/parser/New.mls | 8 ++++---- shared/src/test/scala/mlscript/DiffTests.scala | 2 +- 6 files changed, 24 insertions(+), 31 deletions(-) diff --git a/compiler/shared/test/diff/Lifter.mls b/compiler/shared/test/diff/Lifter.mls index f46f6611e..c0c0f3a68 100644 --- a/compiler/shared/test/diff/Lifter.mls +++ b/compiler/shared/test/diff/Lifter.mls @@ -104,7 +104,7 @@ new C{ fun bar = 17 } //│ |#class| |A|(|x|)| |{|→|#class| |B|{|→|#fun| |foo| |#=| |1|↵|#fun| |bar| |#=| |11|←|↵|}|↵|#fun| |getB| |#=| |#new| |B|{|→|#fun| |foo| |#=| |2|↵|#fun| |bar| |#=| |12|←|↵|}|↵|#fun| |bar| |#=| |13|←|↵|}|↵|#class| |C|#:| |A|{|→|#fun| |getB| |#=| |#new| |B|{|→|#fun| |foo| |#=| |3|↵|#fun| |bar| |#=| |14|←|↵|}|↵|#fun| |bar| |#=| |15|←|↵|}|↵|#new| |C|{|→|#fun| |getB| |#=| |#new| |B|{|→|#fun| |foo| |#=| |4|↵|#fun| |bar| |#=| |16|←|↵|}|↵|#fun| |bar| |#=| |17|←|↵|}| -//│ Parsed: {class A(x,) {class B {fun foo = 1; fun bar = 11}; fun getB = new B { ‹fun foo = 2; fun bar = 12› }; fun bar = 13}; class C: A {fun getB = new B { ‹fun foo = 3; fun bar = 14› }; fun bar = 15}; new C { ‹fun getB = new B { ‹fun foo = 4; fun bar = 16› }; fun bar = 17› }} +//│ Parsed: {class A(x,) {class B {fun foo = 1; fun bar = 11}; fun getB = new B {fun foo = 2; fun bar = 12}; fun bar = 13}; class C: A {fun getB = new B {fun foo = 3; fun bar = 14}; fun bar = 15}; new C {fun getB = new B {fun foo = 4; fun bar = 16}; fun bar = 17}} //│ //│ Lifted: //│ Lifting failed: mlscript.codegen.CodeGenError: Cannot find type B. Class values are not supported in lifter. @@ -142,7 +142,7 @@ class A(x: Int): ({a1: Int} & B & D(x)) { } } //│ |#class| |B|‹|T|›| |{||}|↵|#class| |C| |{||}|↵|#class| |D|(|y|#:| |Int|)| |{||}|↵|#class| |A|‹|T|,| |U|›|(|x|#:| |Int|)|#:| |(|{|a1|#:| |Int|}| |&| |B|‹|T|›| |&| |D|(|x|)|)| |{|→|#fun| |getA|(||)| |#=| |#new| |C|{|→|#fun| |foo|(|x|#:| |T|)| |#=| |x|←|↵|}|←|↵|}| -//│ Parsed: {class B‹T› {}; class C {}; class D(y: Int,) {}; class A‹T, U›(x: Int,): {a1: Int} & B[T] & D[x] {fun getA = () => new C { ‹fun foo = (x: T,) => x› }}} +//│ Parsed: {class B‹T› {}; class C {}; class D(y: Int,) {}; class A‹T, U›(x: Int,): {a1: Int} & B[T] & D[x] {fun getA = () => new C {fun foo = (x: T,) => x}}} //│ //│ Lifted: //│ TypingUnit { @@ -163,7 +163,7 @@ class A(x: Int) extends {a1: Int}, B, D(x){ } } //│ |#class| |B|‹|T|›| |{||}|↵|#class| |C| |{||}|↵|#class| |D|(|y|#:| |Int|)| |{||}|↵|#class| |A|‹|T|,| |U|›|(|x|#:| |Int|)| |#extends| |{|a1|#:| |Int|}|,| |B|‹|T|›|,| |D|(|x|)|{|→|#fun| |getA|(||)| |#=| |#new| |C|{|→|#fun| |foo|(|x|)| |#=| |x|←|↵|}|←|↵|}| -//│ Parsed: {class B‹T› {}; class C {}; class D(y: Int,) {}; class A‹T, U›(x: Int,): '{' {a1: Int} '}', B‹T›, D(x,) {fun getA = () => new C { ‹fun foo = (x,) => x› }}} +//│ Parsed: {class B‹T› {}; class C {}; class D(y: Int,) {}; class A‹T, U›(x: Int,): '{' {a1: Int} '}', B‹T›, D(x,) {fun getA = () => new C {fun foo = (x,) => x}}} //│ //│ Lifted: //│ TypingUnit { @@ -204,7 +204,7 @@ new A(0) { fun getA2 = 2 } //│ |#class| |A|(|x|#:| |Int|)| |{|→|#fun| |getA|#:| |Int| |#=| |0|↵|#fun| |getA1| |#=| |1|←|↵|}|↵|#new| |A|(|0|)| |{|→|#fun| |getA| |#=| |3|↵|#fun| |getA2| |#=| |2|←|↵|}| -//│ Parsed: {class A(x: Int,) {fun getA = 0 : Int; fun getA1 = 1}; (new A)(0,) { ‹fun getA = 3; fun getA2 = 2› }} +//│ Parsed: {class A(x: Int,) {fun getA = 0 : Int; fun getA1 = 1}; (new A)(0,) {fun getA = 3; fun getA2 = 2}} //│ //│ Lifted: //│ TypingUnit { @@ -224,7 +224,7 @@ new A(1) { } } //│ |#class| |A|(|x|)| |{|→|#class| |B|(|y|)| |{| |}|←|↵|}|↵|#new| |A|(|1|)| |{|→|#fun| |getB| |#=| |#new| |B|(|2|)|{|→|#fun| |getB| |#=| |#new| |B|(|3|)|←|↵|}|←|↵|}| -//│ Parsed: {class A(x,) {class B(y,) {}}; (new A)(1,) { ‹fun getB = (new B)(2,) { ‹fun getB = (new B)(3,)› }› }} +//│ Parsed: {class A(x,) {class B(y,) {}}; (new A)(1,) {fun getB = (new B)(2,) {fun getB = (new B)(3,)}}} //│ //│ Lifted: //│ TypingUnit { @@ -256,7 +256,7 @@ new B{ fun getA = funcB } //│ |#class| |A| |{|→|#fun| |getA| |#=| |0|↵|#fun| |funcA| |#=| |10|←|↵|}|↵|#class| |B|#:| |A|{|→|#fun| |getA| |#=| |1|↵|#fun| |funcB| |#=| |11|←|↵|}|↵|#new| |A|↵|#new| |B|↵|#fun| |f|(|x|)| |#=| |#if| |x| |is| |A| |#then| |0| |#else| |1|↵|f|(|#new| |A|{|→|#fun| |getA| |#=| |2|←|↵|}|)|↵|#new| |B|{|→|#fun| |getA| |#=| |funcB|←|↵|}| -//│ Parsed: {class A {fun getA = 0; fun funcA = 10}; class B: A {fun getA = 1; fun funcB = 11}; new A; new B; fun f = (x,) => if (is(x, A,)) then 0 else 1; f(new A { ‹fun getA = 2› },); new B { ‹fun getA = funcB› }} +//│ Parsed: {class A {fun getA = 0; fun funcA = 10}; class B: A {fun getA = 1; fun funcB = 11}; new A; new B; fun f = (x,) => if (is(x, A,)) then 0 else 1; f(new A {fun getA = 2},); new B {fun getA = funcB}} //│ //│ Lifted: //│ TypingUnit { @@ -336,7 +336,7 @@ class A{ } } //│ |#class| |A|{|→|#class| |B|{|→|#fun| |funB| |#=| |1|↵|#fun| |foo| |#=| |100|←|↵|}|↵|#class| |C|#:| |B|{|→|#fun| |funC| |#=| |2|↵|#fun| |foo| |#=| |1000|↵|#fun| |getB| |#=| |#new| |B|←|↵|}|↵|#class| |D|{|→|#fun| |funD| |#=| |3|↵|#fun| |foo| |#=| |10000| |↵|#class| |E|#:| |C|{|→|#fun| |funE| |#=| |4|↵|#fun| |foo| |#=| |100000|↵|#fun| |getD| |#=| |#new| |D|←|↵|}|↵|#class| |F|#:| |E|{|→|#fun| |funF| |#=| |5|↵|#fun| |foo| |#=| |1000000|↵|#fun| |getE| |#=| |#new| |E|{|→|#fun| |foo| |#=| |0|←|↵|}|←|↵|}|←|↵|}|←|↵|}| -//│ Parsed: {class A {class B {fun funB = 1; fun foo = 100}; class C: B {fun funC = 2; fun foo = 1000; fun getB = new B}; class D {fun funD = 3; fun foo = 10000; class E: C {fun funE = 4; fun foo = 100000; fun getD = new D}; class F: E {fun funF = 5; fun foo = 1000000; fun getE = new E { ‹fun foo = 0› }}}}} +//│ Parsed: {class A {class B {fun funB = 1; fun foo = 100}; class C: B {fun funC = 2; fun foo = 1000; fun getB = new B}; class D {fun funD = 3; fun foo = 10000; class E: C {fun funE = 4; fun foo = 100000; fun getD = new D}; class F: E {fun funF = 5; fun foo = 1000000; fun getE = new E {fun foo = 0}}}}} //│ //│ Lifted: //│ TypingUnit { @@ -394,7 +394,7 @@ let x = new A{ } } //│ |#class| |A|(|x|)| |{|→|#fun| |foo| |#=| |0|↵|#fun| |bar| |#=| |x|←|↵|}|↵|#let| |x| |#=| |#new| |A|{|→|#fun| |foo| |#=| |1|↵|#fun| |newFun| |#=| |2|↵|#fun| |bar| |#=| |#new| |A|(|foo|)|{|→|#fun| |foo| |#=| |bar| |+| |1|↵|#fun| |bar2| |#=| |newFun| |+| |1|←|↵|}|←|↵|}| -//│ Parsed: {class A(x,) {fun foo = 0; fun bar = x}; let x = new A { ‹fun foo = 1; fun newFun = 2; fun bar = (new A)(foo,) { ‹fun foo = +(bar, 1,); fun bar2 = +(newFun, 1,)› }› }} +//│ Parsed: {class A(x,) {fun foo = 0; fun bar = x}; let x = new A {fun foo = 1; fun newFun = 2; fun bar = (new A)(foo,) {fun foo = +(bar, 1,); fun bar2 = +(newFun, 1,)}}} //│ //│ Lifted: //│ TypingUnit { @@ -421,7 +421,7 @@ new A{ } } //│ |#class| |A| |{||}|↵|#new| |A|{|→|#fun| |foo| |#=| |1|↵|#fun| |bar| |#=| |#new| |A|{|→|#fun| |foo1| |#=| |foo|↵|#fun| |bar1| |#=| |#new| |A|{|→|#fun| |foo2| |#=| |foo|↵|#fun| |bar2| |#=| |#new| |A|{|→|#fun| |foo3| |#=| |foo|↵|#fun| |bar3| |#=| |#new| |A|{|→|#fun| |foo4| |#=| |foo|↵|#fun| |bar4| |#=| |0|←|↵|}|←|↵|}|←|↵|}|←|↵|}|←|↵|}| -//│ Parsed: {class A {}; new A { ‹fun foo = 1; fun bar = new A { ‹fun foo1 = foo; fun bar1 = new A { ‹fun foo2 = foo; fun bar2 = new A { ‹fun foo3 = foo; fun bar3 = new A { ‹fun foo4 = foo; fun bar4 = 0› }› }› }› }› }} +//│ Parsed: {class A {}; new A {fun foo = 1; fun bar = new A {fun foo1 = foo; fun bar1 = new A {fun foo2 = foo; fun bar2 = new A {fun foo3 = foo; fun bar3 = new A {fun foo4 = foo; fun bar4 = 0}}}}}} //│ //│ Lifted: //│ TypingUnit {class A$1([]) {}; Code(List(new A$1([]) {}))} diff --git a/compiler/shared/test/diff/LifterBlks.mls b/compiler/shared/test/diff/LifterBlks.mls index 9ea8e45f0..61ac5eedf 100644 --- a/compiler/shared/test/diff/LifterBlks.mls +++ b/compiler/shared/test/diff/LifterBlks.mls @@ -52,7 +52,7 @@ class A(y){} let f = x => new A(0){fun bar = x+y} f(0) //│ |#class| |A|(|y|)|{||}|↵|#let| |f| |#=| |x| |#=>| |#new| |A|(|0|)|{|#fun| |bar| |#=| |x|+|y|}|↵|f|(|0|)| -//│ Parsed: {class A(y,) {}; let f = (x,) => (new A)(0,) { ‹fun bar = +(x, y,)› }; f(0,)} +//│ Parsed: {class A(y,) {}; let f = (x,) => (new A)(0,) {fun bar = +(x, y,)}; f(0,)} //│ //│ Lifted: //│ TypingUnit { @@ -74,7 +74,7 @@ class A(x){ } } //│ |#class| |A|(|x|)|{|→|#fun| |w| |#=| |x|↵|#fun| |foo|(|y|)| |#=| |→|#class| |B|(|z|)|{|→|#fun| |bar| |#=| |x|+|y|+|z|←|↵|}|↵|#new| |B|(|0|)|{|→|#fun| |bar| |#=| |w|+|y|+|z|←|↵|}|←|←|↵|}| -//│ Parsed: {class A(x,) {fun w = x; fun foo = (y,) => {class B(z,) {fun bar = +(+(x, y,), z,)}; (new B)(0,) { ‹fun bar = +(+(w, y,), z,)› }}}} +//│ Parsed: {class A(x,) {fun w = x; fun foo = (y,) => {class B(z,) {fun bar = +(+(x, y,), z,)}; (new B)(0,) {fun bar = +(+(w, y,), z,)}}}} //│ //│ Lifted: //│ TypingUnit { @@ -276,7 +276,7 @@ fun ctx(a,b) = fun apply(x) = a+x }, b) //│ |#class| |Func|‹|T|,| |U|›| |{|→|#fun| |apply|#:| |T| |#=>| |U|←|↵|}|↵|#class| |Lambda|‹|T|,| |U|›| |#:| |Func|‹|T|,| |U|›| |{||}|↵|#fun| |ctx|(|a|,|b|)| |#=|→|#fun| |foo|(|f|#:| |Func|,| |x|)| |#=| |→|f|.apply|(|x|)|←|↵|foo|(|#new| |Lambda|{|→|#fun| |apply|(|x|)| |#=| |a|+|x|←|↵|}|,| |b|)|←| -//│ Parsed: {class Func‹T, U› {fun apply: T -> U}; class Lambda‹T, U›: Func[T, U] {}; fun ctx = (a, b,) => {fun foo = (f: Func, x,) => {(f).apply(x,)}; foo(new Lambda { ‹fun apply = (x,) => +(a, x,)› }, b,)}} +//│ Parsed: {class Func‹T, U› {fun apply: T -> U}; class Lambda‹T, U›: Func[T, U] {}; fun ctx = (a, b,) => {fun foo = (f: Func, x,) => {(f).apply(x,)}; foo(new Lambda {fun apply = (x,) => +(a, x,)}, b,)}} //│ //│ Lifted: //│ TypingUnit { diff --git a/shared/src/main/scala/mlscript/helpers.scala b/shared/src/main/scala/mlscript/helpers.scala index 8dfd7c02e..b6154bd40 100644 --- a/shared/src/main/scala/mlscript/helpers.scala +++ b/shared/src/main/scala/mlscript/helpers.scala @@ -434,7 +434,7 @@ trait NuDeclImpl extends Located { self: NuDecl => def name: Str = nameVar.name def showBody: Str = this match { case fd: NuFunDef => fd.rhs.fold(_.print(false), _.showDbg2) - case td: NuTypeDef => td.body.showDbgTop + case td: NuTypeDef => td.body.showDbg } def describe: Str = this match { case _: NuFunDef => "definition" @@ -471,13 +471,6 @@ trait TypingUnitImpl extends Located { self: TypingUnit => case d: NuDecl => d.showDbg case c: Constructor => c.showDbg case e => lastWords(s"Unexpected typing unit entity: $e") - }.mkString("‹", "; ", "›") - - def showDbgTop: Str = entities.iterator.map { - case t: Term => t.print(false) - case d: NuDecl => d.showDbg - case c: Constructor => c.showDbg - case e => lastWords(s"Unexpected typing unit entity: $e") }.mkString("{", "; ", "}") lazy val children: List[Located] = entities @@ -613,8 +606,8 @@ trait TermImpl extends StatementImpl { self: Term => s"case ${s.showDbg} of { ${c.print(true)} }" |> bra case Subs(a, i) => s"(${a.showDbg})[${i.showDbg}]" case Assign(lhs, rhs) => s" ${lhs.showDbg} <- ${rhs.showDbg}" |> bra - case New(S((at, ar)), bod) => s"new ${at.showDbg2}(${ar.showDbg}) ${bod.showDbgTop}" |> bra - case New(N, bod) => s"new ${bod.showDbgTop}" |> bra + case New(S((at, ar)), bod) => s"new ${at.showDbg2}(${ar.showDbg}) ${bod.showDbg}" |> bra + case New(N, bod) => s"new ${bod.showDbg}" |> bra case NuNew(cls) => s"new ${cls.showDbg}" |> bra case If(body, els) => s"if ${body.showDbg}" + els.fold("")(" else " + _.showDbg) |> bra case TyApp(lhs, targs) => s"${lhs.showDbg}‹${targs.iterator.map(_.showDbg2).mkString(", ")}›" @@ -625,7 +618,7 @@ trait TermImpl extends StatementImpl { self: Term => case Eqn(lhs, rhs) => s"${lhs.showDbg} = ${rhs.showDbg}" case AdtMatchWith(cond, arms) => s"match ${cond.showDbg} with ${arms.map (patmat => s"${patmat.pat.showDbg} -> ${patmat.rhs.showDbg}").mkString (" | ") }" - case Rft(bse, tu) => s"${bse.showDbg} { ${tu.showDbg} }" + case Rft(bse, tu) => s"${bse.showDbg} ${tu.showDbg}" }} def toTypeRaise(implicit raise: Raise): Type = toType match { diff --git a/shared/src/test/diff/parser/BasicSyntax.mls b/shared/src/test/diff/parser/BasicSyntax.mls index 5c4c9b09d..f525ad016 100644 --- a/shared/src/test/diff/parser/BasicSyntax.mls +++ b/shared/src/test/diff/parser/BasicSyntax.mls @@ -319,18 +319,18 @@ f[1, 2, 3] f{} //│ |f|{||}| -//│ Parsed: {f { ‹› }} +//│ Parsed: {f {}} f{1} //│ |f|{|1|}| -//│ Parsed: {f { ‹1› }} +//│ Parsed: {f {1}} f{1, 2, 3} //│ |f|{|1|,| |2|,| |3|}| //│ ╔══[PARSE ERROR] Unexpected comma here //│ ║ l.328: f{1, 2, 3} //│ ╙── ^ -//│ Parsed: {f { ‹1› }} +//│ Parsed: {f {1}} f 1,, 2 diff --git a/shared/src/test/diff/parser/New.mls b/shared/src/test/diff/parser/New.mls index 2ce52058d..f10a90908 100644 --- a/shared/src/test/diff/parser/New.mls +++ b/shared/src/test/diff/parser/New.mls @@ -38,19 +38,19 @@ new A of 1, 2, 3 new A { fun x = 1 } //│ |#new| |A| |{| |#fun| |x| |#=| |1| |}| -//│ Parsed: {new A { ‹fun x = 1› }} +//│ Parsed: {new A {fun x = 1}} new A() { fun x = 1 } //│ |#new| |A|(||)| |{| |#fun| |x| |#=| |1| |}| -//│ Parsed: {(new A)() { ‹fun x = 1› }} +//│ Parsed: {(new A)() {fun x = 1}} new A(1, 2, 3) { fun x = 1 } //│ |#new| |A|(|1|,| |2|,| |3|)| |{| |#fun| |x| |#=| |1| |}| -//│ Parsed: {(new A)(1, 2, 3,) { ‹fun x = 1› }} +//│ Parsed: {(new A)(1, 2, 3,) {fun x = 1}} new A of 1, 2, 3 { fun x = 1 } //│ |#new| |A| |#of| |1|,| |2|,| |3| |{| |#fun| |x| |#=| |1| |}| -//│ Parsed: {new A(1, 2, 3 { ‹fun x = 1› },)} +//│ Parsed: {new A(1, 2, 3 {fun x = 1},)} :pe diff --git a/shared/src/test/scala/mlscript/DiffTests.scala b/shared/src/test/scala/mlscript/DiffTests.scala index 1defcdd46..b5772437f 100644 --- a/shared/src/test/scala/mlscript/DiffTests.scala +++ b/shared/src/test/scala/mlscript/DiffTests.scala @@ -427,7 +427,7 @@ class DiffTests val res = p.parseAll(p.typingUnit) if (parseOnly) - output("Parsed: " + res.showDbgTop) + output(s"Parsed: ${res.showDbg}") if (mode.showParse) output(s"AST: $res")