diff --git a/shared/src/main/scala/mlscript/JSBackend.scala b/shared/src/main/scala/mlscript/JSBackend.scala index 7057e7699..9c8b3d34f 100644 --- a/shared/src/main/scala/mlscript/JSBackend.scala +++ b/shared/src/main/scala/mlscript/JSBackend.scala @@ -1401,6 +1401,16 @@ abstract class JSTestBackend extends JSBackend(allowUnresolvedSymbols = false) { case _ => die } + otherStmts.foreach { + case fd @ NuFunDef(isLetRec, Var(nme), symNme, _, L(body)) => + val isByname = isLetRec.isEmpty + val isByvalueRecIn = if (isByname) None else Some(true) + val bodyIsLam = body match { case _: Lam => true case _ => false } + val symb = symNme.map(_.name) + scope.declareValue(nme, isByvalueRecIn, bodyIsLam, symb) + case _ => () + } + // don't pass `otherStmts` to the top-level module, because we need to execute them one by one later val topModule = topLevelScope.declareTopModule("TypingUnit", Nil, typeDefs, true) val moduleIns = topLevelScope.declareValue("typing_unit", Some(false), false, N) @@ -1416,16 +1426,6 @@ abstract class JSTestBackend extends JSBackend(allowUnresolvedSymbols = false) { (zeroWidthSpace + JSIdent("e") + zeroWidthSpace).log() :: Nil ) - otherStmts.foreach { - case fd @ NuFunDef(isLetRec, Var(nme), symNme, _, L(body)) if isLetRec.getOrElse(true) => - val isByname = isLetRec.isEmpty - val isByvalueRecIn = if (isByname) None else Some(true) - val bodyIsLam = body match { case _: Lam => true case _ => false } - val symb = symNme.map(_.name) - scope.declareValue(nme, isByvalueRecIn, bodyIsLam, symb) - case _ => () - } - // TODO Improve: (Lionel) I find this logic very strange! What's going on here? // Why are we declaring some things above AND below? // Why does the fact that a binding is recursive affect its declaration in the OUTER scope? diff --git a/shared/src/test/diff/codegen/AuxiliaryConstructors.mls b/shared/src/test/diff/codegen/AuxiliaryConstructors.mls index 3fd393ed2..5c729795c 100644 --- a/shared/src/test/diff/codegen/AuxiliaryConstructors.mls +++ b/shared/src/test/diff/codegen/AuxiliaryConstructors.mls @@ -464,11 +464,11 @@ n.ll //│ class TypingUnit19 {} //│ const typing_unit19 = new TypingUnit19; //│ // Query 1 -//│ globalThis.m = g(1); +//│ globalThis.m1 = g(1); //│ // Query 2 -//│ globalThis.n = m(2); +//│ globalThis.n1 = m1(2); //│ // Query 3 -//│ res = n.ll; +//│ res = n1.ll; //│ // End of generated code //│ m //│ = [Function (anonymous)] @@ -487,7 +487,7 @@ let mm = new M() //│ class TypingUnit21 {} //│ const typing_unit21 = new TypingUnit21; //│ // Query 1 -//│ globalThis.mm = new M.class(); +//│ globalThis.mm1 = new M.class(); //│ // End of generated code //│ mm //│ = M {} diff --git a/shared/src/test/diff/codegen/ConstructorStmt.mls b/shared/src/test/diff/codegen/ConstructorStmt.mls index a61301347..4f769b8f3 100644 --- a/shared/src/test/diff/codegen/ConstructorStmt.mls +++ b/shared/src/test/diff/codegen/ConstructorStmt.mls @@ -105,7 +105,7 @@ let aa = A(42) //│ class TypingUnit5 {} //│ const typing_unit5 = new TypingUnit5; //│ // Query 1 -//│ globalThis.aa = A(42); +//│ globalThis.aa1 = A(42); //│ // End of generated code //│ aa //│ = A {} @@ -119,7 +119,7 @@ aa //│ class TypingUnit6 {} //│ const typing_unit6 = new TypingUnit6; //│ // Query 1 -//│ res = aa; +//│ res = aa1; //│ // End of generated code //│ res //│ = A {} @@ -131,7 +131,7 @@ let ab = A(0) //│ class TypingUnit7 {} //│ const typing_unit7 = new TypingUnit7; //│ // Query 1 -//│ globalThis.ab = A(0); +//│ globalThis.ab1 = A(0); //│ // End of generated code //│ ab //│ = A {} @@ -408,9 +408,9 @@ www.add(42) //│ class TypingUnit15 {} //│ const typing_unit15 = new TypingUnit15; //│ // Query 1 -//│ globalThis.www = W(); +//│ globalThis.www1 = W(); //│ // Query 2 -//│ res = www.add(42); +//│ res = www1.add(42); //│ // End of generated code //│ www //│ = W {} diff --git a/shared/src/test/diff/codegen/Modules.mls b/shared/src/test/diff/codegen/Modules.mls index 884d2a792..82d6fa856 100644 --- a/shared/src/test/diff/codegen/Modules.mls +++ b/shared/src/test/diff/codegen/Modules.mls @@ -9,7 +9,6 @@ module test { // hello //│ } -:ge // * FIXME :js fun y = 1 module Foo { @@ -19,10 +18,36 @@ module Foo { //│ module Foo { //│ fun x: 1 //│ } -//│ Code generation encountered an error: -//│ unresolved symbol y +//│ // Prelude +//│ class TypingUnit1 { +//│ #Foo; +//│ constructor() { +//│ } +//│ get Foo() { +//│ const qualifier = this; +//│ if (this.#Foo === undefined) { +//│ class Foo { +//│ constructor() { +//│ } +//│ get x() { +//│ return y(); +//│ } +//│ } +//│ this.#Foo = new Foo(); +//│ this.#Foo.class = Foo; +//│ } +//│ return this.#Foo; +//│ } +//│ } +//│ const typing_unit1 = new TypingUnit1; +//│ globalThis.Foo = typing_unit1.Foo; +//│ // Query 1 +//│ globalThis.y = function y() { +//│ return 1; +//│ }; +//│ // End of generated code + -:ge // * FIXME :js module Foo { fun x = y @@ -32,7 +57,33 @@ fun y = 1 //│ fun x: 1 //│ } //│ fun y: 1 -//│ Code generation encountered an error: -//│ unresolved symbol y +//│ // Prelude +//│ class TypingUnit2 { +//│ #Foo; +//│ constructor() { +//│ } +//│ get Foo() { +//│ const qualifier = this; +//│ if (this.#Foo === undefined) { +//│ class Foo { +//│ constructor() { +//│ } +//│ get x() { +//│ return y1(); +//│ } +//│ } +//│ this.#Foo = new Foo(); +//│ this.#Foo.class = Foo; +//│ } +//│ return this.#Foo; +//│ } +//│ } +//│ const typing_unit2 = new TypingUnit2; +//│ globalThis.Foo = typing_unit2.Foo; +//│ // Query 1 +//│ globalThis.y1 = function y1() { +//│ return 1; +//│ }; +//│ // End of generated code diff --git a/shared/src/test/diff/codegen/Nested.mls b/shared/src/test/diff/codegen/Nested.mls index 10843c74a..227d0c7a2 100644 --- a/shared/src/test/diff/codegen/Nested.mls +++ b/shared/src/test/diff/codegen/Nested.mls @@ -78,9 +78,9 @@ bb.b //│ class TypingUnit1 {} //│ const typing_unit1 = new TypingUnit1; //│ // Query 1 -//│ globalThis.bb = A.B(A.a); +//│ globalThis.bb1 = A.B(A.a); //│ // Query 2 -//│ res = bb.b; +//│ res = bb1.b; //│ // End of generated code //│ bb //│ = B {} @@ -241,9 +241,9 @@ ee.x //│ class TypingUnit5 {} //│ const typing_unit5 = new TypingUnit5; //│ // Query 1 -//│ globalThis.ee = D.createE(42); +//│ globalThis.ee1 = D.createE(42); //│ // Query 2 -//│ res = ee.x; +//│ res = ee1.x; //│ // End of generated code //│ ee //│ = E {} @@ -361,13 +361,13 @@ gg.sum //│ class TypingUnit7 {} //│ const typing_unit7 = new TypingUnit7; //│ // Query 1 -//│ globalThis.es = E(1); +//│ globalThis.es1 = E(1); //│ // Query 2 -//│ globalThis.fff = es.F(2); +//│ globalThis.fff1 = es1.F(2); //│ // Query 3 -//│ globalThis.gg = fff.G(3); +//│ globalThis.gg1 = fff1.G(3); //│ // Query 4 -//│ res = gg.sum; +//│ res = gg1.sum; //│ // End of generated code //│ es //│ = E {} @@ -559,11 +559,11 @@ i.x //│ class TypingUnit10 {} //│ const typing_unit10 = new TypingUnit10; //│ // Query 1 -//│ globalThis.jj = G.H.J(42); +//│ globalThis.jj1 = G.H.J(42); //│ // Query 2 -//│ globalThis.i = jj.ii(2); +//│ globalThis.i1 = jj1.ii(2); //│ // Query 3 -//│ res = i.x; +//│ res = i1.x; //│ // End of generated code //│ jj //│ = J {} @@ -666,9 +666,9 @@ j.i.x //│ class TypingUnit12 {} //│ const typing_unit12 = new TypingUnit12; //│ // Query 1 -//│ globalThis.j = H.J(42); +//│ globalThis.j1 = H.J(42); //│ // Query 2 -//│ res = j.i.x; +//│ res = j1.i.x; //│ // End of generated code //│ j //│ = J {} @@ -757,11 +757,11 @@ ij.incY //│ const typing_unit13 = new TypingUnit13; //│ globalThis.I = typing_unit13.I; //│ // Query 1 -//│ globalThis.i1 = I(1); +//│ globalThis.i3 = I(1); //│ // Query 2 -//│ globalThis.ij = i1.J(0); +//│ globalThis.ij1 = i3.J(0); //│ // Query 3 -//│ res = ij.incY; +//│ res = ij1.incY; //│ // End of generated code //│ i //│ = I {} @@ -890,9 +890,9 @@ let n = J.N(2) //│ class TypingUnit15 {} //│ const typing_unit15 = new TypingUnit15; //│ // Query 1 -//│ globalThis.m = J.M(); +//│ globalThis.m1 = J.M(); //│ // Query 2 -//│ globalThis.n = J.N(2); +//│ globalThis.n1 = J.N(2); //│ // End of generated code //│ m //│ = M {} diff --git a/shared/src/test/diff/codegen/New.mls b/shared/src/test/diff/codegen/New.mls index 9909f20df..8636a83c8 100644 --- a/shared/src/test/diff/codegen/New.mls +++ b/shared/src/test/diff/codegen/New.mls @@ -46,7 +46,7 @@ let c = C //│ class TypingUnit3 {} //│ const typing_unit3 = new TypingUnit3; //│ // Query 1 -//│ globalThis.c = C; +//│ globalThis.c1 = C; //│ // End of generated code //│ c //│ = [class C] @@ -93,7 +93,7 @@ let c = C //│ class TypingUnit8 {} //│ const typing_unit8 = new TypingUnit8; //│ // Query 1 -//│ globalThis.c1 = C; +//│ globalThis.c3 = C; //│ // End of generated code //│ c //│ = [Function (anonymous)] { diff --git a/shared/src/test/diff/codegen/NewMatching.mls b/shared/src/test/diff/codegen/NewMatching.mls index 50d2dbc1d..acdef0ef4 100644 --- a/shared/src/test/diff/codegen/NewMatching.mls +++ b/shared/src/test/diff/codegen/NewMatching.mls @@ -136,7 +136,7 @@ fun foo(s) = //│ // Query 1 //│ globalThis.foo = function foo(s) { //│ return ((() => { -//│ return s instanceof Some.class ? (([t]) => ((b) => b + t.x)(s2.value))(Some.unapply(s)) : 0; +//│ return s instanceof Some.class ? (([t]) => ((b) => b + t.x)(s21.value))(Some.unapply(s)) : 0; //│ })()); //│ }; //│ // End of generated code diff --git a/shared/src/test/diff/codegen/NuReplHost.mls b/shared/src/test/diff/codegen/NuReplHost.mls index d4805d1c8..c5aaf4563 100644 --- a/shared/src/test/diff/codegen/NuReplHost.mls +++ b/shared/src/test/diff/codegen/NuReplHost.mls @@ -33,7 +33,7 @@ let r = foo(1) //│ └─┬ Query 2/2 //│ ├── Prelude: //│ ├── Code: -//│ ├── globalThis.r = foo(1); +//│ ├── globalThis.r1 = foo(1); //│ └── Reply: [runtime error] Error: an error was thrown //│ r //│ Runtime error: @@ -44,7 +44,7 @@ r //│ nothing //│ res //│ Runtime error: -//│ ReferenceError: r is not defined +//│ ReferenceError: r1 is not defined diff --git a/shared/src/test/diff/codegen/SymbolicOps.mls b/shared/src/test/diff/codegen/SymbolicOps.mls index 9dd61cb78..37e42ce6a 100644 --- a/shared/src/test/diff/codegen/SymbolicOps.mls +++ b/shared/src/test/diff/codegen/SymbolicOps.mls @@ -14,7 +14,7 @@ let r = succ >> succ //│ class TypingUnit1 {} //│ const typing_unit1 = new TypingUnit1; //│ // Query 1 -//│ globalThis.r = compose(succ, succ); +//│ globalThis.r1 = compose(succ, succ); //│ // End of generated code //│ r //│ = [Function (anonymous)] @@ -65,7 +65,7 @@ let f = (>>) //│ class TypingUnit7 {} //│ const typing_unit7 = new TypingUnit7; //│ // Query 1 -//│ globalThis.f = compose; +//│ globalThis.f1 = compose; //│ // End of generated code //│ f //│ = [Function: compose] @@ -315,7 +315,7 @@ fun (:-D) dd(a, b) = a + b val (->) f(x, y) = [x, y] //│ val (->) f: forall 'a 'b. ('a, 'b) -> ['a, 'b] //│ f -//│ = [Function: f1] +//│ = [Function: f3] 12 -> 34 //│ [12, 34] @@ -326,7 +326,7 @@ val (->) f(x, y) = [x, y] let (->) _ = f //│ let (->) _: forall 'a 'b. ('a, 'b) -> ['a, 'b] //│ _ -//│ = [Function: f1] +//│ = [Function: f3] :js 12 -> 34 @@ -335,7 +335,7 @@ let (->) _ = f //│ class TypingUnit42 {} //│ const typing_unit42 = new TypingUnit42; //│ // Query 1 -//│ res = _(12, 34); +//│ res = _1(12, 34); //│ // End of generated code //│ res //│ = [ 12, 34 ] diff --git a/shared/src/test/diff/mlscript/Sequence.mls b/shared/src/test/diff/mlscript/Sequence.mls index 919c7251b..6c52dff4c 100644 --- a/shared/src/test/diff/mlscript/Sequence.mls +++ b/shared/src/test/diff/mlscript/Sequence.mls @@ -4,7 +4,7 @@ let test(x) = log(x); x + 1 //│ let test: Int -> Int //│ test -//│ = [Function: test] +//│ = [Function: test1] test(log("here we go"); 123) //│ Int diff --git a/shared/src/test/diff/nu/FlatIndentFuns.mls b/shared/src/test/diff/nu/FlatIndentFuns.mls index 3a58afdd0..77ace9e70 100644 --- a/shared/src/test/diff/nu/FlatIndentFuns.mls +++ b/shared/src/test/diff/nu/FlatIndentFuns.mls @@ -20,7 +20,7 @@ y => x + y //│ let r: Int -> Int -> Int //│ r -//│ = [Function: r] +//│ = [Function: r1] r(1)(2) //│ Int @@ -59,6 +59,6 @@ x + y //│ ╙── //│ let r: Int -> Int -> Int //│ r -//│ = [Function: r1] +//│ = [Function: r3] diff --git a/shared/src/test/diff/nu/FlatMonads_repro.mls b/shared/src/test/diff/nu/FlatMonads_repro.mls index 938516f49..1fe5bef9a 100644 --- a/shared/src/test/diff/nu/FlatMonads_repro.mls +++ b/shared/src/test/diff/nu/FlatMonads_repro.mls @@ -48,7 +48,7 @@ let ri(f) = Bind(Pure(42), f) //│ where //│ 'CC :> 42 //│ ri -//│ = [Function: ri] +//│ = [Function: ri1] ri(Pure) //│ Bind['CC, 'AA] diff --git a/shared/src/test/diff/nu/HeungTung.mls b/shared/src/test/diff/nu/HeungTung.mls index 091301565..264a54170 100644 --- a/shared/src/test/diff/nu/HeungTung.mls +++ b/shared/src/test/diff/nu/HeungTung.mls @@ -202,7 +202,7 @@ type Res = M(T) let f = x => [x, x] //│ let f: forall 'a. 'a -> ['a, 'a] //│ f -//│ = [Function: f2] +//│ = [Function: f3] [f(1), f(true)] //│ [[1, 1], [true, true]] diff --git a/shared/src/test/diff/nu/LamPatterns.mls b/shared/src/test/diff/nu/LamPatterns.mls index 58aa85eb8..cb78cf349 100644 --- a/shared/src/test/diff/nu/LamPatterns.mls +++ b/shared/src/test/diff/nu/LamPatterns.mls @@ -24,12 +24,12 @@ let f = Some => 0 //│ class TypingUnit2 {} //│ const typing_unit2 = new TypingUnit2; //│ // Query 1 -//│ globalThis.f = function f(Some) { +//│ globalThis.f1 = function f1(Some) { //│ return 0; //│ }; //│ // End of generated code //│ f -//│ = [Function: f] +//│ = [Function: f1] // :e // TODO f(Some) diff --git a/shared/src/test/diff/nu/LetRec.mls b/shared/src/test/diff/nu/LetRec.mls index c5e80d777..74f8a3f58 100644 --- a/shared/src/test/diff/nu/LetRec.mls +++ b/shared/src/test/diff/nu/LetRec.mls @@ -147,7 +147,7 @@ let rec f = let foo = foo //│ let foo: nothing //│ Code generation encountered an error: -//│ unresolved symbol foo +//│ unguarded recursive use of by-value binding foo // FIXME should work @@ -165,15 +165,14 @@ let foo = foo + 1 // FIXME let foo = foo.x //│ let foo: nothing -//│ foo -//│ = undefined +//│ Code generation encountered an error: +//│ unguarded recursive use of by-value binding foo // :e // FIXME -:re +:ge foo()() //│ nothing -//│ res -//│ Runtime error: -//│ TypeError: foo2 is not a function +//│ Code generation encountered an error: +//│ unguarded recursive use of by-value binding foo diff --git a/shared/src/test/diff/nu/LocalLets.mls b/shared/src/test/diff/nu/LocalLets.mls index 211987ae0..15717f5de 100644 --- a/shared/src/test/diff/nu/LocalLets.mls +++ b/shared/src/test/diff/nu/LocalLets.mls @@ -32,6 +32,6 @@ let E(x) = new E(1) //│ ╙── ^ //│ let E: anything -> error //│ E -//│ = [Function: E1] +//│ = [Function: E2] diff --git a/shared/src/test/diff/nu/MIscPoly.mls b/shared/src/test/diff/nu/MIscPoly.mls index 3d9c94a5a..34235988a 100644 --- a/shared/src/test/diff/nu/MIscPoly.mls +++ b/shared/src/test/diff/nu/MIscPoly.mls @@ -69,7 +69,7 @@ r() //│ nothing //│ res //│ Runtime error: -//│ TypeError: r is not a function +//│ TypeError: r1 is not a function diff --git a/shared/src/test/diff/nu/Misc.mls b/shared/src/test/diff/nu/Misc.mls index 821a12d2c..a0aa87e20 100644 --- a/shared/src/test/diff/nu/Misc.mls +++ b/shared/src/test/diff/nu/Misc.mls @@ -65,7 +65,7 @@ f of [1, 2] let f = (x, y) => x + y //│ let f: (Int, Int) -> Int //│ f -//│ = [Function: f4] +//│ = [Function: f5] f(1, 2) //│ Int @@ -96,7 +96,7 @@ let f = ((x, y)) => x + y //│ ╙── ^^^^^^ //│ let f: ([Int, Int]) -> Int //│ f -//│ = [Function: f5] +//│ = [Function: f7] :e f(1, 2) @@ -132,7 +132,7 @@ f[1, 2] //│ ╙── ^^^^^^^ //│ ([Int, Int]) -> Int //│ res -//│ = [Function: f5] +//│ = [Function: f7] :pe @@ -142,14 +142,14 @@ let f = (((x, y))) => x + y //│ ╙── ^^^^^^ //│ let f: ([Int, Int]) -> Int //│ f -//│ = [Function: f6] +//│ = [Function: f9] // * TODO maybe parse as type lambda? let f = [x, y] => x + y //│ let f: ([Int, Int]) -> Int //│ f -//│ = [Function: f7] +//│ = [Function: f11] :e f(1, 2) @@ -173,7 +173,7 @@ f([1, 2]) let f = ([x, y]) => x + y //│ let f: ([Int, Int]) -> Int //│ f -//│ = [Function: f8] +//│ = [Function: f13] f([1, 2]) //│ Int @@ -197,7 +197,7 @@ f(1, 2) let f = [[[x, y]]] => x + y //│ let f: ([[[Int, Int]]]) -> Int //│ f -//│ = [Function: f9] +//│ = [Function: f15] :e f([[1, 2]]) diff --git a/shared/src/test/diff/nu/NamedArgs.mls b/shared/src/test/diff/nu/NamedArgs.mls index 8c4d4606f..c846ee548 100644 --- a/shared/src/test/diff/nu/NamedArgs.mls +++ b/shared/src/test/diff/nu/NamedArgs.mls @@ -116,9 +116,9 @@ test(0, y: 200) //│ class TypingUnit13 {} //│ const typing_unit13 = new TypingUnit13; //│ // Query 1 -//│ globalThis.tmp = 2; +//│ globalThis.tmp1 = 2; //│ // Query 2 -//│ res = test1(0, tmp); +//│ res = test1(0, tmp1); //│ // Query 3 //│ res = test1(0, 200); //│ // End of generated code @@ -171,11 +171,11 @@ fff(y: 2, z: y_1 + 1, x: z_1 - 2) //│ class TypingUnit17 {} //│ const typing_unit17 = new TypingUnit17; //│ // Query 1 -//│ globalThis["y_1"] = 2; +//│ globalThis["y_11"] = 2; //│ // Query 2 -//│ globalThis["z_1"] = 3; +//│ globalThis["z_11"] = 3; //│ // Query 3 -//│ res = ((z_2) => ((x_1) => fff(x_1, 2, z_2))(z_1 - 2))(y_1 + 1); +//│ res = ((z_2) => ((x_1) => fff(x_1, 2, z_2))(z_11 - 2))(y_11 + 1); //│ // End of generated code //│ y_1 //│ = 2 diff --git a/shared/src/test/diff/nu/NestedRecords.mls b/shared/src/test/diff/nu/NestedRecords.mls index ebe7bbcbd..ca216f478 100644 --- a/shared/src/test/diff/nu/NestedRecords.mls +++ b/shared/src/test/diff/nu/NestedRecords.mls @@ -4,7 +4,7 @@ let f(x) = [x, x] //│ let f: forall 'a. 'a -> ['a, 'a] //│ f -//│ = [Function: f] +//│ = [Function: f1] let a = { u: f(f(f(1))), v: f(f(f(1))) } //│ let a: {u: [[[1, 1], [1, 1]], [[1, 1], [1, 1]]], v: [[[1, 1], [1, 1]], [[1, 1], [1, 1]]]} diff --git a/shared/src/test/diff/nu/NewNew.mls b/shared/src/test/diff/nu/NewNew.mls index c135ca38a..8ab334a69 100644 --- a/shared/src/test/diff/nu/NewNew.mls +++ b/shared/src/test/diff/nu/NewNew.mls @@ -103,7 +103,7 @@ f(1) //│ error //│ res //│ Runtime error: -//│ TypeError: f4 is not a function +//│ TypeError: f9 is not a function :e new Foo("2") diff --git a/shared/src/test/diff/nu/Refinements.mls b/shared/src/test/diff/nu/Refinements.mls index 3aa89616d..2311c3c10 100644 --- a/shared/src/test/diff/nu/Refinements.mls +++ b/shared/src/test/diff/nu/Refinements.mls @@ -85,15 +85,17 @@ let r = new {} //│ Code generation encountered an error: //│ Unsupported `new` class term: Bra(rcd = true, Rcd()) +:ge r : Object //│ Object -//│ res -//│ = {} +//│ Code generation encountered an error: +//│ unguarded recursive use of by-value binding r +:ge r with { x: 1 } //│ error & {x: 1} -//│ res -//│ = { x: 1 } +//│ Code generation encountered an error: +//│ unguarded recursive use of by-value binding r let r = { x: 0 } @@ -104,16 +106,16 @@ let r = { x: 0 } :e r : Object //│ ╔══[ERROR] Type mismatch in type ascription: -//│ ║ l.105: r : Object +//│ ║ l.107: r : Object //│ ║ ^ //│ ╟── record literal of type `{x: 0}` is not an instance of type `Object` -//│ ║ l.99: let r = { x: 0 } -//│ ║ ^ +//│ ║ l.101: let r = { x: 0 } +//│ ║ ^ //│ ╟── but it flows into reference with expected type `Object` -//│ ║ l.105: r : Object +//│ ║ l.107: r : Object //│ ║ ^ //│ ╟── Note: constraint arises from type reference: -//│ ║ l.105: r : Object +//│ ║ l.107: r : Object //│ ╙── ^^^^^^ //│ Object //│ res @@ -138,16 +140,16 @@ o : {} :e o : Object //│ ╔══[ERROR] Type mismatch in type ascription: -//│ ║ l.139: o : Object +//│ ║ l.141: o : Object //│ ║ ^ //│ ╟── type `anything` is not an instance of type `Object` -//│ ║ l.132: fun o : {} +//│ ║ l.134: fun o : {} //│ ║ ^^ //│ ╟── but it flows into reference with expected type `Object` -//│ ║ l.139: o : Object +//│ ║ l.141: o : Object //│ ║ ^ //│ ╟── Note: constraint arises from type reference: -//│ ║ l.139: o : Object +//│ ║ l.141: o : Object //│ ╙── ^^^^^^ //│ Object @@ -169,10 +171,10 @@ o : Object :e let d = D & { f: 0 } //│ ╔══[ERROR] Illegal use of reserved operator: & -//│ ║ l.170: let d = D & { f: 0 } +//│ ║ l.172: let d = D & { f: 0 } //│ ╙── ^ //│ ╔══[ERROR] identifier not found: & -//│ ║ l.170: let d = D & { f: 0 } +//│ ║ l.172: let d = D & { f: 0 } //│ ╙── ^ //│ let d: error diff --git a/shared/src/test/diff/nu/Res.mls b/shared/src/test/diff/nu/Res.mls index 0f7f660b6..e8936ec34 100644 --- a/shared/src/test/diff/nu/Res.mls +++ b/shared/src/test/diff/nu/Res.mls @@ -19,7 +19,7 @@ res(1) let res = x => x + 2 //│ let res: Int -> Int //│ res -//│ = [Function: res1] +//│ = [Function: res2] res(1) //│ Int diff --git a/shared/src/test/diff/nu/Vals.mls b/shared/src/test/diff/nu/Vals.mls index 5a5a62a81..e90080f1b 100644 --- a/shared/src/test/diff/nu/Vals.mls +++ b/shared/src/test/diff/nu/Vals.mls @@ -18,20 +18,21 @@ val d = 1 //│ val c: Int //│ val d: 1 //│ Code generation encountered an error: -//│ unresolved symbol d +//│ unguarded recursive use of by-value binding d // :e // FIXME should not type check +:ge val a = a //│ val a: nothing -//│ a -//│ = 1 +//│ Code generation encountered an error: +//│ unguarded recursive use of by-value binding a val f(x) = x //│ val f: forall 'a. 'a -> 'a //│ f -//│ = [Function: f] +//│ = [Function: f1] f(123) //│ 123