From 5f5ffed31e63dd9fd6931cc2ce5b355476cfc148 Mon Sep 17 00:00:00 2001 From: Anson Yeung Date: Wed, 13 Nov 2024 21:55:45 +0800 Subject: [PATCH] Fix missing semicolons --- .../scala/hkmc2/codegen/js/JSBuilder.scala | 8 +++---- .../src/test/mlscript-compile/Example.mjs | 4 ++-- .../src/test/mlscript-compile/Option.mjs | 8 +++---- .../src/test/mlscript-compile/Predef.mjs | 10 ++++---- .../src/test/mlscript-compile/Stack.mjs | 4 ++-- .../test/mlscript/basics/MultiParamLists.mls | 18 +++++++------- .../src/test/mlscript/codegen/CaseOfCase.mls | 8 +++---- .../test/mlscript/codegen/CaseShorthand.mls | 20 ++++++++++------ .../test/mlscript/codegen/ClassInClass.mls | 6 ++--- .../src/test/mlscript/codegen/ClassInFun.mls | 4 ++-- .../test/mlscript/codegen/ClassMatching.mls | 24 +++++++++---------- .../src/test/mlscript/codegen/Comma.mls | 6 ++--- .../test/mlscript/codegen/DelayedLetInit.mls | 2 +- .../src/test/mlscript/codegen/EarlyReturn.mls | 4 ++-- .../src/test/mlscript/codegen/FunInClass.mls | 8 +++---- .../src/test/mlscript/codegen/Functions.mls | 2 +- .../test/mlscript/codegen/FunctionsThis.mls | 2 +- .../src/test/mlscript/codegen/GlobalThis.mls | 6 ++--- .../src/test/mlscript/codegen/Hygiene.mls | 4 ++-- .../src/test/mlscript/codegen/IfThenElse.mls | 6 ++--- .../src/test/mlscript/codegen/Lambdas.mls | 2 +- .../test/mlscript/codegen/ModuleMethods.mls | 2 +- .../src/test/mlscript/codegen/OptMatch.mls | 12 +++++----- .../test/mlscript/codegen/ParamClasses.mls | 4 ++-- .../test/mlscript/codegen/PlainClasses.mls | 12 +++++----- .../shared/src/test/mlscript/codegen/Repl.mls | 2 +- .../src/test/mlscript/codegen/SetIn.mls | 8 +++---- .../shared/src/test/mlscript/codegen/This.mls | 6 ++--- .../src/test/mlscript/codegen/While.mls | 20 ++++++++-------- .../ucs/normalization/SimplePairMatches.mls | 20 ++++++++-------- .../ucs/normalization/UnifySubScrutinees.mls | 12 +++++----- 31 files changed, 130 insertions(+), 124 deletions(-) diff --git a/hkmc2/shared/src/main/scala/hkmc2/codegen/js/JSBuilder.scala b/hkmc2/shared/src/main/scala/hkmc2/codegen/js/JSBuilder.scala index 285d4a666..a631ff8bb 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/codegen/js/JSBuilder.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/codegen/js/JSBuilder.scala @@ -220,7 +220,7 @@ class JSBuilder extends CodeBuilder: case N => doc"$res;${returningTerm(rst)}" doc" # ${resJS}" case Return(res, true) => doc" # ${result(res)}" - case Return(res, false) => doc" # return ${result(res)}" + case Return(res, false) => doc" # return ${result(res)};" // TODO factor out common logic case Match(scrut, Case.Lit(syntax.Tree.BoolLit(true)) -> trm :: Nil, els, rest) => @@ -262,13 +262,13 @@ class JSBuilder extends CodeBuilder: doc" # /* $msg */" case Throw(res) => - doc" # throw ${result(res)}" + doc" # throw ${result(res)};" case Break(lbl, false) => - doc" # break ${getVar(lbl)}" + doc" # break ${getVar(lbl)};" case Break(lbl, true) => - doc" # continue ${getVar(lbl)}" + doc" # continue ${getVar(lbl)};" case Label(lbl, bod, rst) => scope.allocateName(lbl) diff --git a/hkmc2/shared/src/test/mlscript-compile/Example.mjs b/hkmc2/shared/src/test/mlscript-compile/Example.mjs index db49bdc05..9e266277b 100644 --- a/hkmc2/shared/src/test/mlscript-compile/Example.mjs +++ b/hkmc2/shared/src/test/mlscript-compile/Example.mjs @@ -4,10 +4,10 @@ const Example$class = class Example { } funnySlash(f, arg) { - return f(arg) + return f(arg); } inc(x) { - return x + 1 + return x + 1; } toString() { return "Example"; } }; const Example = new Example$class; diff --git a/hkmc2/shared/src/test/mlscript-compile/Option.mjs b/hkmc2/shared/src/test/mlscript-compile/Option.mjs index 9e32d924d..60d08d4b6 100644 --- a/hkmc2/shared/src/test/mlscript-compile/Option.mjs +++ b/hkmc2/shared/src/test/mlscript-compile/Option.mjs @@ -29,17 +29,17 @@ const Option$class = class Option { } isDefined(x) { if (x instanceof this.Some.class) { - return true + return true; } else { if (x instanceof this.None.class) { - return false + return false; } else { - throw new globalThis.Error("match error") + throw new globalThis.Error("match error"); } } } test() { - return Predef.pipe(2134, Predef.print) + return Predef.pipe(2134, Predef.print); } toString() { return "Option"; } }; const Option = new Option$class; diff --git a/hkmc2/shared/src/test/mlscript-compile/Predef.mjs b/hkmc2/shared/src/test/mlscript-compile/Predef.mjs index ece24d8c9..d847b55e5 100644 --- a/hkmc2/shared/src/test/mlscript-compile/Predef.mjs +++ b/hkmc2/shared/src/test/mlscript-compile/Predef.mjs @@ -3,20 +3,20 @@ const Predef$class = class Predef { } id(x) { - return x + return x; } pipe(x1, f) { - return f(x1) + return f(x1); } call(receiver, f1) { return (arg) => { - return f1.call(receiver, arg) - } + return f1.call(receiver, arg); + }; } print(x2) { let tmp; tmp = String(x2); - return console.log(tmp) + return console.log(tmp); } toString() { return "Predef"; } }; const Predef = new Predef$class; diff --git a/hkmc2/shared/src/test/mlscript-compile/Stack.mjs b/hkmc2/shared/src/test/mlscript-compile/Stack.mjs index 2f4129a9d..278b4e7bf 100644 --- a/hkmc2/shared/src/test/mlscript-compile/Stack.mjs +++ b/hkmc2/shared/src/test/mlscript-compile/Stack.mjs @@ -20,9 +20,9 @@ const Stack$class = class Stack { } isEmpty(xs) { if (xs instanceof this.Nil.class) { - return true + return true; } else { - return false + return false; } } toString() { return "Stack"; } diff --git a/hkmc2/shared/src/test/mlscript/basics/MultiParamLists.mls b/hkmc2/shared/src/test/mlscript/basics/MultiParamLists.mls index 1c0fc4879..79b61b641 100644 --- a/hkmc2/shared/src/test/mlscript/basics/MultiParamLists.mls +++ b/hkmc2/shared/src/test/mlscript/basics/MultiParamLists.mls @@ -6,7 +6,7 @@ fun f(n1: Int): Int = n1 //│ JS: -//│ function f(n1) { return n1 }; undefined +//│ function f(n1) { return n1; }; undefined f(42) //│ JS: @@ -15,7 +15,7 @@ f(42) fun f(n1: Int)(n2: Int): Int = (10 * n1 + n2) //│ JS: -//│ function f(n1) { return (n2) => { let tmp; tmp = 10 * n1; return tmp + n2 } }; undefined +//│ function f(n1) { return (n2) => { let tmp; tmp = 10 * n1; return tmp + n2; }; }; undefined f(4)(2) //│ JS: @@ -31,9 +31,9 @@ fun f(n1: Int)(n2: Int)(n3: Int): Int = 10 * (10 * n1 + n2) + n3 //│ tmp = 10 * n1; //│ tmp1 = tmp + n2; //│ tmp2 = 10 * tmp1; -//│ return tmp2 + n3 -//│ } -//│ } +//│ return tmp2 + n3; +//│ }; +//│ }; //│ }; //│ undefined @@ -54,10 +54,10 @@ fun f(n1: Int)(n2: Int)(n3: Int)(n4: Int): Int = 10 * (10 * (10 * n1 + n2) + n3) //│ tmp2 = 10 * tmp1; //│ tmp3 = tmp2 + n3; //│ tmp4 = 10 * tmp3; -//│ return tmp4 + n4 -//│ } -//│ } -//│ } +//│ return tmp4 + n4; +//│ }; +//│ }; +//│ }; //│ }; //│ undefined diff --git a/hkmc2/shared/src/test/mlscript/codegen/CaseOfCase.mls b/hkmc2/shared/src/test/mlscript/codegen/CaseOfCase.mls index 5f4de34d3..273211444 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/CaseOfCase.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/CaseOfCase.mls @@ -29,19 +29,19 @@ fun test(x) = //│ if (x instanceof globalThis.None.class) { //│ tmp1 = globalThis.None; //│ } else { -//│ throw new globalThis.Error("match error") +//│ throw new globalThis.Error("match error"); //│ } //│ } //│ scrut = tmp1; //│ if (scrut instanceof globalThis.Some.class) { //│ param01 = scrut.value; //│ v1 = param01; -//│ return globalThis.log(v1) +//│ return globalThis.log(v1); //│ } else { //│ if (scrut instanceof globalThis.None.class) { -//│ return globalThis.log("none") +//│ return globalThis.log("none"); //│ } else { -//│ throw new globalThis.Error("match error") +//│ throw new globalThis.Error("match error"); //│ } //│ } //│ }; diff --git a/hkmc2/shared/src/test/mlscript/codegen/CaseShorthand.mls b/hkmc2/shared/src/test/mlscript/codegen/CaseShorthand.mls index 066cac786..afe4ddeb0 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/CaseShorthand.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/CaseShorthand.mls @@ -11,21 +11,27 @@ case x then x :sjs case { x then x } //│ JS: -//│ (caseScrut) => { let x; x = caseScrut; return x } +//│ (caseScrut) => { let x; x = caseScrut; return x; } //│ = [Function (anonymous)] :sjs x => if x is 0 then true //│ JS: -//│ (x) => { if (x === 0) { return true } else { throw new this.Error("match error") } } +//│ (x) => { if (x === 0) { return true; } else { throw new this.Error("match error"); } } //│ = [Function (anonymous)] :sjs case 0 then true //│ JS: -//│ (caseScrut) => { if (caseScrut === 0) { return true } else { throw new this.Error("match error") } } +//│ (caseScrut) => { +//│ if (caseScrut === 0) { +//│ return true; +//│ } else { +//│ throw new this.Error("match error"); +//│ } +//│ } //│ = [Function (anonymous)] :sjs @@ -33,7 +39,7 @@ case 0 then true _ then false //│ JS: -//│ (caseScrut) => { if (caseScrut === 0) { return true } else { return false } } +//│ (caseScrut) => { if (caseScrut === 0) { return true; } else { return false; } } //│ = [Function (anonymous)] class Some(value) @@ -46,12 +52,12 @@ val isDefined = case //│ JS: //│ this.isDefined = (caseScrut) => { //│ if (caseScrut instanceof this.Some.class) { -//│ return true +//│ return true; //│ } else { //│ if (caseScrut instanceof this.None.class) { -//│ return false +//│ return false; //│ } else { -//│ throw new this.Error("match error") +//│ throw new this.Error("match error"); //│ } //│ } //│ }; diff --git a/hkmc2/shared/src/test/mlscript/codegen/ClassInClass.mls b/hkmc2/shared/src/test/mlscript/codegen/ClassInClass.mls index c25a6020b..4bb931c21 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/ClassInClass.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/ClassInClass.mls @@ -40,7 +40,7 @@ class Outer(a, b) with //│ this$Outer.b, //│ this.c, //│ d -//│ ] +//│ ]; //│ } //│ toString() { return "Inner(" + this.c + ")"; } //│ }; @@ -51,12 +51,12 @@ class Outer(a, b) with //│ globalThis.log(tmp2) //│ } //│ o1(c) { -//│ return this.Inner(c) +//│ return this.Inner(c); //│ } //│ o2(c1, d) { //│ let tmp; //│ tmp = this.Inner(c1); -//│ return tmp.i1(d) +//│ return tmp.i1(d); //│ } //│ toString() { return "Outer(" + this.a + ", " + this.b + ")"; } //│ }; diff --git a/hkmc2/shared/src/test/mlscript/codegen/ClassInFun.mls b/hkmc2/shared/src/test/mlscript/codegen/ClassInFun.mls index 61d18e10e..1a847a0d5 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/ClassInFun.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/ClassInFun.mls @@ -16,7 +16,7 @@ fun test(a) = //│ } //│ toString() { return "C"; } //│ }; -//│ return new C() +//│ return new C(); //│ }; //│ undefined @@ -41,7 +41,7 @@ fun test(x) = //│ toString() { return "Foo(" + this.a + ", " + this.b + ")"; } //│ }; //│ tmp = x + 1; -//│ return Foo(x, tmp) +//│ return Foo(x, tmp); //│ }; //│ undefined diff --git a/hkmc2/shared/src/test/mlscript/codegen/ClassMatching.mls b/hkmc2/shared/src/test/mlscript/codegen/ClassMatching.mls index f05f97cd7..459a8b4c3 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/ClassMatching.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/ClassMatching.mls @@ -19,7 +19,7 @@ if Some(0) is Some(x) then x //│ x = param0; //│ x //│ } else { -//│ throw new this.Error("match error") +//│ throw new this.Error("match error"); //│ } //│ = 0 @@ -38,7 +38,7 @@ if s is //│ x = param0; //│ x //│ } else { -//│ throw new this.Error("match error") +//│ throw new this.Error("match error"); //│ } //│ = 0 @@ -66,9 +66,9 @@ x => if x is Some(x) then x //│ if (x instanceof this.Some.class) { //│ param0 = x.value; //│ x1 = param0; -//│ return x1 +//│ return x1; //│ } else { -//│ throw new this.Error("match error") +//│ throw new this.Error("match error"); //│ } //│ } //│ = [Function (anonymous)] @@ -127,15 +127,15 @@ fun f(x) = if x is //│ x1 = param0; //│ scrut = x1 > 0; //│ if (scrut) { -//│ return 42 +//│ return 42; //│ } else { -//│ return globalThis.log("oops") +//│ return globalThis.log("oops"); //│ } //│ } else { //│ if (x instanceof globalThis.None.class) { -//│ return "ok" +//│ return "ok"; //│ } else { -//│ return globalThis.log("oops") +//│ return globalThis.log("oops"); //│ } //│ } //│ }; @@ -167,16 +167,16 @@ fun f(x) = if x is //│ if (x instanceof globalThis.Some.class) { //│ param01 = x.value; //│ u = param01; -//│ return u +//│ return u; //│ } else { //│ if (x instanceof globalThis.Pair.class) { //│ param0 = x.fst; //│ param1 = x.snd; //│ a = param0; //│ b = param1; -//│ return a + b +//│ return a + b; //│ } else { -//│ throw new globalThis.Error("match error") +//│ throw new globalThis.Error("match error"); //│ } //│ } //│ }; @@ -212,7 +212,7 @@ fun f(x) = log of if x is //│ tmp = "oops"; //│ } //│ } -//│ return globalThis.log(tmp) +//│ return globalThis.log(tmp); //│ }; //│ undefined diff --git a/hkmc2/shared/src/test/mlscript/codegen/Comma.mls b/hkmc2/shared/src/test/mlscript/codegen/Comma.mls index 2b5f7ddd6..c4e697fde 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/Comma.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/Comma.mls @@ -7,15 +7,15 @@ fun f() = console.log("ok"), 42 //│ JS: -//│ function f() { let tmp; tmp = globalThis.console.log("ok"); return 42 }; undefined +//│ function f() { let tmp; tmp = globalThis.console.log("ok"); return 42; }; undefined fun f() = { console.log("ok"), 42 } //│ JS: -//│ function f() { let tmp; tmp = globalThis.console.log("ok"); return 42 }; undefined +//│ function f() { let tmp; tmp = globalThis.console.log("ok"); return 42; }; undefined fun f() = console.log("ok"), 42 //│ JS: -//│ function f() { return globalThis.console.log("ok") }; 42 +//│ function f() { return globalThis.console.log("ok"); }; 42 //│ = 42 diff --git a/hkmc2/shared/src/test/mlscript/codegen/DelayedLetInit.mls b/hkmc2/shared/src/test/mlscript/codegen/DelayedLetInit.mls index 29377e652..bff8c02c3 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/DelayedLetInit.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/DelayedLetInit.mls @@ -32,7 +32,7 @@ z = 1 fun f() = 1 //│ JS: -//│ function f() { return 1 }; undefined +//│ function f() { return 1; }; undefined f //│ JS: diff --git a/hkmc2/shared/src/test/mlscript/codegen/EarlyReturn.mls b/hkmc2/shared/src/test/mlscript/codegen/EarlyReturn.mls index 150afc2e4..7c9f968a4 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/EarlyReturn.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/EarlyReturn.mls @@ -27,11 +27,11 @@ fun f(x) = //│ scrut = x < 0; //│ if (scrut) { //│ tmp = globalThis.log("whoops"); -//│ return 0 +//│ return 0; //│ } else { //│ tmp1 = undefined; //│ } -//│ return x + 1 +//│ return x + 1; //│ }; //│ undefined diff --git a/hkmc2/shared/src/test/mlscript/codegen/FunInClass.mls b/hkmc2/shared/src/test/mlscript/codegen/FunInClass.mls index fd800f9ef..9ddd4830a 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/FunInClass.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/FunInClass.mls @@ -35,7 +35,7 @@ fun test(a) = //│ a, //│ this.b, //│ c -//│ ] +//│ ]; //│ } //│ g(d) { //│ @@ -46,13 +46,13 @@ fun test(a) = //│ this$Inner.b, //│ d, //│ e -//│ ] +//│ ]; //│ }; -//│ return h(d) +//│ return h(d); //│ } //│ toString() { return "Inner(" + this.b + ")"; } //│ }; -//│ return Inner(42) +//│ return Inner(42); //│ }; //│ undefined diff --git a/hkmc2/shared/src/test/mlscript/codegen/Functions.mls b/hkmc2/shared/src/test/mlscript/codegen/Functions.mls index c4f8c26b6..602216763 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/Functions.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/Functions.mls @@ -78,7 +78,7 @@ outer(100)(200) :showRepl fun test1(x) = test2(x) fun test2(y) = y + 1 -//│ REPL> Sending: try { function test1(x) { return globalThis.test2(x) }; function test2(y) { return y + 1 }; undefined } catch (e) { console.log('\u200B' + e.stack + '\u200B'); } +//│ REPL> Sending: try { function test1(x) { return globalThis.test2(x); }; function test2(y) { return y + 1; }; undefined } catch (e) { console.log('\u200B' + e.stack + '\u200B'); } //│ REPL> Collected: //│ > undefined //│ REPL> Parsed: diff --git a/hkmc2/shared/src/test/mlscript/codegen/FunctionsThis.mls b/hkmc2/shared/src/test/mlscript/codegen/FunctionsThis.mls index 7ad8618a7..e61b8eb72 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/FunctionsThis.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/FunctionsThis.mls @@ -9,7 +9,7 @@ val x = 2 fun foo() = x + 1 //│ JS: -//│ this.x = 2; function foo() { return globalThis.x + 1 }; undefined +//│ this.x = 2; function foo() { return globalThis.x + 1; }; undefined //│ x = 2 :sjs diff --git a/hkmc2/shared/src/test/mlscript/codegen/GlobalThis.mls b/hkmc2/shared/src/test/mlscript/codegen/GlobalThis.mls index 90b86fb9b..8a2368a70 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/GlobalThis.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/GlobalThis.mls @@ -18,7 +18,7 @@ globalThis :re if false then 0 //│ JS: -//│ let scrut; scrut = false; if (scrut) { 0 } else { throw new this.Error("match error") } +//│ let scrut; scrut = false; if (scrut) { 0 } else { throw new this.Error("match error"); } //│ ═══[RUNTIME ERROR] Error: match error // * This one uses `globalThis.Error` @@ -33,9 +33,9 @@ foo() //│ let scrut; //│ scrut = false; //│ if (scrut) { -//│ return 0 +//│ return 0; //│ } else { -//│ throw new globalThis.Error("match error") +//│ throw new globalThis.Error("match error"); //│ } //│ }; //│ this.foo() diff --git a/hkmc2/shared/src/test/mlscript/codegen/Hygiene.mls b/hkmc2/shared/src/test/mlscript/codegen/Hygiene.mls index dcb0cbd1a..2c13dd5d0 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/Hygiene.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/Hygiene.mls @@ -11,7 +11,7 @@ module Test with //│ this.x = 12; //│ } //│ foo() { -//│ return globalThis.Test.x +//│ return globalThis.Test.x; //│ } //│ toString() { return "Test"; } //│ }; @@ -43,7 +43,7 @@ let f = () => x let x = 2 f() //│ JS: -//│ this.x = 1; this.f = () => { return this.x }; this.x = 2; this.f() +//│ this.x = 1; this.f = () => { return this.x; }; this.x = 2; this.f() //│ = 2 //│ f = [Function (anonymous)] //│ x = 2 diff --git a/hkmc2/shared/src/test/mlscript/codegen/IfThenElse.mls b/hkmc2/shared/src/test/mlscript/codegen/IfThenElse.mls index 63efc4766..8447d8f2c 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/IfThenElse.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/IfThenElse.mls @@ -12,7 +12,7 @@ if true then 1 else 0 :sjs let f = x => if x then log("ok") else log("ko") //│ JS: -//│ this.f = (x) => { if (x) { return this.log("ok") } else { return this.log("ko") } }; undefined +//│ this.f = (x) => { if (x) { return this.log("ok"); } else { return this.log("ko"); } }; undefined //│ f = [Function (anonymous)] f(true) @@ -33,7 +33,7 @@ let f = x => log((if x then "ok" else "ko") + "!") //│ tmp = "ko"; //│ } //│ tmp1 = tmp + "!"; -//│ return this.log(tmp1) +//│ return this.log(tmp1); //│ }; //│ undefined //│ f = [Function (anonymous)] @@ -53,7 +53,7 @@ let f = x => log((if x and x then "ok" else "ko") + "!") //│ tmp = "ko"; //│ } //│ tmp1 = tmp + "!"; -//│ return this.log(tmp1) +//│ return this.log(tmp1); //│ }; //│ undefined //│ f = [Function (anonymous)] diff --git a/hkmc2/shared/src/test/mlscript/codegen/Lambdas.mls b/hkmc2/shared/src/test/mlscript/codegen/Lambdas.mls index 78a1eb9aa..1e43f8277 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/Lambdas.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/Lambdas.mls @@ -8,7 +8,7 @@ x => let y = x y //│ JS: -//│ (x) => { let y; y = x; return y } +//│ (x) => { let y; y = x; return y; } //│ = [Function (anonymous)] diff --git a/hkmc2/shared/src/test/mlscript/codegen/ModuleMethods.mls b/hkmc2/shared/src/test/mlscript/codegen/ModuleMethods.mls index 02167eec5..37be9037c 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/ModuleMethods.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/ModuleMethods.mls @@ -15,7 +15,7 @@ module Example with //│ return [ //│ x, //│ this.a -//│ ] +//│ ]; //│ } //│ toString() { return "Example"; } //│ }; diff --git a/hkmc2/shared/src/test/mlscript/codegen/OptMatch.mls b/hkmc2/shared/src/test/mlscript/codegen/OptMatch.mls index c47ffb4d5..a68f990ab 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/OptMatch.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/OptMatch.mls @@ -12,12 +12,12 @@ fun isDefined(x) = if x is //│ JS: //│ function isDefined(x) { //│ if (x instanceof globalThis.Some.class) { -//│ return true +//│ return true; //│ } else { //│ if (x instanceof globalThis.None.class) { -//│ return false +//│ return false; //│ } else { -//│ throw new globalThis.Error("match error") +//│ throw new globalThis.Error("match error"); //│ } //│ } //│ }; @@ -39,12 +39,12 @@ val isDefined = case //│ let param0; //│ if (caseScrut instanceof this.Some.class) { //│ param0 = caseScrut.value; -//│ return true +//│ return true; //│ } else { //│ if (caseScrut instanceof this.None.class) { -//│ return false +//│ return false; //│ } else { -//│ throw new this.Error("match error") +//│ throw new this.Error("match error"); //│ } //│ } //│ }; diff --git a/hkmc2/shared/src/test/mlscript/codegen/ParamClasses.mls b/hkmc2/shared/src/test/mlscript/codegen/ParamClasses.mls index 4c68ebd25..4b5328ba0 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/ParamClasses.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/ParamClasses.mls @@ -64,7 +64,7 @@ Foo(1).a fun foo(y) = Foo(y) foo(27) //│ JS: -//│ function foo(y) { return globalThis.Foo(y) }; this.foo(27) +//│ function foo(y) { return globalThis.Foo(y); }; this.foo(27) //│ = Foo { a: 27 } @@ -140,7 +140,7 @@ class Inner(c) with //│ globalThis.log(this.c) //│ } //│ i1(d) { -//│ return this.c + d +//│ return this.c + d; //│ } //│ toString() { return "Inner(" + this.c + ")"; } //│ }; diff --git a/hkmc2/shared/src/test/mlscript/codegen/PlainClasses.mls b/hkmc2/shared/src/test/mlscript/codegen/PlainClasses.mls index 359eb985d..dd070a2b5 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/PlainClasses.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/PlainClasses.mls @@ -69,7 +69,7 @@ fun test() = //│ toString() { return "Foo"; } //│ }; //│ tmp = globalThis.log("ok"); -//│ return Foo +//│ return Foo; //│ }; //│ undefined @@ -106,7 +106,7 @@ class Foo with //│ this.#y = tmp; //│ } //│ z() { -//│ return this.#y + this.x +//│ return this.#y + this.x; //│ } //│ toString() { return "Foo"; } //│ }; @@ -133,10 +133,10 @@ class Foo with //│ globalThis.log("hello") //│ } //│ z1() { -//│ return 5 +//│ return 5; //│ } //│ z2() { -//│ return 6 +//│ return 6; //│ } //│ toString() { return "Foo"; } //│ }; @@ -153,12 +153,12 @@ class Foo with //│ this.x = 1; //│ } //│ foo(y) { -//│ return this.x + y +//│ return this.x + y; //│ } //│ bar(z) { //│ let tmp; //│ tmp = this.foo(z); -//│ return tmp + 1 +//│ return tmp + 1; //│ } //│ toString() { return "Foo"; } //│ }; diff --git a/hkmc2/shared/src/test/mlscript/codegen/Repl.mls b/hkmc2/shared/src/test/mlscript/codegen/Repl.mls index 2a922619a..f3cd239e3 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/Repl.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/Repl.mls @@ -7,7 +7,7 @@ val res: Int :showRepl fun res() = 1 -//│ REPL> Sending: try { function res() { return 1 }; undefined } catch (e) { console.log('\u200B' + e.stack + '\u200B'); } +//│ REPL> Sending: try { function res() { return 1; }; undefined } catch (e) { console.log('\u200B' + e.stack + '\u200B'); } //│ REPL> Collected: //│ > undefined //│ REPL> Parsed: diff --git a/hkmc2/shared/src/test/mlscript/codegen/SetIn.mls b/hkmc2/shared/src/test/mlscript/codegen/SetIn.mls index bcc65304d..d343b8459 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/SetIn.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/SetIn.mls @@ -82,7 +82,7 @@ example() //│ let x, get_x, old, tmp, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6; //│ x = 0; //│ get_x = () => { -//│ return x +//│ return x; //│ }; //│ old = x; //│ try { @@ -97,7 +97,7 @@ example() //│ } //│ tmp5 = globalThis.log(x); //│ tmp6 = get_x(); -//│ return globalThis.log(tmp6) +//│ return globalThis.log(tmp6); //│ }; //│ this.example() //│ > 1 @@ -120,7 +120,7 @@ example() //│ let x, get_x, y, old, tmp, tmp1, tmp2, tmp3, tmp4, tmp5; //│ x = 0; //│ get_x = () => { -//│ return x +//│ return x; //│ }; //│ old = x; //│ try { @@ -135,7 +135,7 @@ example() //│ tmp3 = globalThis.log(x); //│ tmp4 = get_x(); //│ tmp5 = globalThis.log(tmp4); -//│ return y +//│ return y; //│ }; //│ this.example() //│ > 1 diff --git a/hkmc2/shared/src/test/mlscript/codegen/This.mls b/hkmc2/shared/src/test/mlscript/codegen/This.mls index 4a055dbf0..3c6c4cfb3 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/This.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/This.mls @@ -5,7 +5,7 @@ fun test(x) = [this.a, x] //│ JS: -//│ function test(x) { return [ globalThis.a, x ] }; undefined +//│ function test(x) { return [ globalThis.a, x ]; }; undefined test(123) //│ = [ undefined, 123 ] @@ -29,13 +29,13 @@ module Test with //│ this.a = 2; //│ } //│ test1(x) { -//│ return globalThis.test(x) +//│ return globalThis.test(x); //│ } //│ test2(x1) { //│ return [ //│ this.a, //│ x1 -//│ ] +//│ ]; //│ } //│ toString() { return "Test"; } //│ }; diff --git a/hkmc2/shared/src/test/mlscript/codegen/While.mls b/hkmc2/shared/src/test/mlscript/codegen/While.mls index 0e00ce400..70f79b2c9 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/While.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/While.mls @@ -13,13 +13,13 @@ //│ scrut = true; //│ if (scrut) { //│ tmp = 0; -//│ continue tmp1 +//│ continue tmp1; //│ } else { -//│ throw new this.Error("match error") +//│ throw new this.Error("match error"); //│ } //│ break; //│ } -//│ return tmp +//│ return tmp; //│ } //│ = [Function (anonymous)] @@ -61,7 +61,7 @@ while x //│ tmp = this.log("Hello World"); //│ this.x = false; //│ tmp1 = undefined; -//│ continue tmp2 +//│ continue tmp2; //│ } else { //│ tmp1 = 42; //│ } @@ -116,13 +116,13 @@ while //│ tmp = i + 1; //│ i = tmp; //│ tmp1 = undefined; -//│ continue tmp2 +//│ continue tmp2; //│ } else { -//│ throw new this.Error("match error") +//│ throw new this.Error("match error"); //│ } //│ break; //│ } -//│ return tmp1 +//│ return tmp1; //│ } //│ = [Function (anonymous)] @@ -206,13 +206,13 @@ fun f(ls) = //│ tl = param1; //│ ls1 = tl; //│ tmp = globalThis.log(h); -//│ continue tmp1 +//│ continue tmp1; //│ } else { //│ tmp = globalThis.log("Done!"); //│ } //│ break; //│ } -//│ return tmp +//│ return tmp; //│ }; //│ undefined @@ -242,7 +242,7 @@ while log("Hello World"); false //│ ║ l.239: then 0(0) //│ ╙── ^^^^ //│ ═══[ERROR] Unrecognized term split (false literal). -//│ ═══[COMPILATION ERROR] [Uncaught SyntaxError] Unexpected token 'break' +//│ ═══[RUNTIME ERROR] Error: match error :fixme while { log("Hello World"), false } diff --git a/hkmc2/shared/src/test/mlscript/ucs/normalization/SimplePairMatches.mls b/hkmc2/shared/src/test/mlscript/ucs/normalization/SimplePairMatches.mls index 0e2f30907..5c291191f 100644 --- a/hkmc2/shared/src/test/mlscript/ucs/normalization/SimplePairMatches.mls +++ b/hkmc2/shared/src/test/mlscript/ucs/normalization/SimplePairMatches.mls @@ -16,15 +16,15 @@ x => if x is Pair(A, B) then 1 //│ param1 = x.b; //│ if (param0 instanceof this.A) { //│ if (param1 instanceof this.B) { -//│ return 1 +//│ return 1; //│ } else { -//│ throw new this.Error("match error") +//│ throw new this.Error("match error"); //│ } //│ } else { -//│ throw new this.Error("match error") +//│ throw new this.Error("match error"); //│ } //│ } else { -//│ throw new this.Error("match error") +//│ throw new this.Error("match error"); //│ } //│ } //│ = [Function (anonymous)] @@ -43,23 +43,23 @@ fun f(x) = if x is //│ param1 = x.b; //│ if (param0 instanceof globalThis.A) { //│ if (param1 instanceof globalThis.A) { -//│ return 1 +//│ return 1; //│ } else { -//│ throw new globalThis.Error("match error") +//│ throw new globalThis.Error("match error"); //│ } //│ } else { //│ if (param0 instanceof globalThis.B) { //│ if (param1 instanceof globalThis.B) { -//│ return 2 +//│ return 2; //│ } else { -//│ throw new globalThis.Error("match error") +//│ throw new globalThis.Error("match error"); //│ } //│ } else { -//│ throw new globalThis.Error("match error") +//│ throw new globalThis.Error("match error"); //│ } //│ } //│ } else { -//│ throw new globalThis.Error("match error") +//│ throw new globalThis.Error("match error"); //│ } //│ }; //│ undefined diff --git a/hkmc2/shared/src/test/mlscript/ucs/normalization/UnifySubScrutinees.mls b/hkmc2/shared/src/test/mlscript/ucs/normalization/UnifySubScrutinees.mls index 80df3d0ae..e044aed80 100644 --- a/hkmc2/shared/src/test/mlscript/ucs/normalization/UnifySubScrutinees.mls +++ b/hkmc2/shared/src/test/mlscript/ucs/normalization/UnifySubScrutinees.mls @@ -43,14 +43,14 @@ fun sum(acc, xs) = //│ > xs@30 is Cons($param0@31, $param1@32) and //│ > let x@33 = $param0@31#0 //│ > let xs@34 = $param1@32#0 -//│ > else globalThis:block#3#666.sum‹member:sum›(builtin:+#82(acc@29#666, x@33#666), xs@34#666) +//│ > else globalThis:block#3#666.sum‹member:sum›(builtin:+#87(acc@29#666, x@33#666), xs@34#666) //│ > xs@30 is Nil then acc@29#666 //│ Normalized: //│ > if //│ > xs@30 is Cons($param0@31, $param1@32) and //│ > let x@33 = $param0@31#0 //│ > let xs@34 = $param1@32#0 -//│ > else globalThis:block#3#666.sum‹member:sum›(builtin:+#82(acc@29#666, x@33#666), xs@34#666) +//│ > else globalThis:block#3#666.sum‹member:sum›(builtin:+#87(acc@29#666, x@33#666), xs@34#666) //│ > xs@30 is Nil then acc@29#666 :todo @@ -70,12 +70,12 @@ fun test(xs) = //│ > let x@52 = $param0@45#1 //│ > $param1@46 is Cons($param0@48, $param1@49) and //│ > let y@53 = $param0@48#1 -//│ > $param1@49 is Nil then builtin:+#83(x@52#666, y@53#666) +//│ > $param1@49 is Nil then builtin:+#88(x@52#666, y@53#666) //│ > xs@39 is Some($param0@40) and $param0@40 is Cons($param0@41, $param1@42) and $param0@41 is "mul" and $param1@42 is Cons($param0@45, $param1@46) and //│ > let x@47 = $param0@45#0 //│ > $param1@46 is Cons($param0@48, $param1@49) and //│ > let y@50 = $param0@48#0 -//│ > $param1@49 is Nil then builtin:*#23(x@47#666, y@50#666) +//│ > $param1@49 is Nil then builtin:*#26(x@47#666, y@50#666) //│ > xs@39 is Some($param0@40) and $param0@40 is Cons($param0@41, $param1@42) and $param0@41 is "sum" and //│ > let xs@43 = $param1@42#0 //│ > else globalThis:block#3#666.sum‹member:sum›(0, xs@43#666) @@ -89,12 +89,12 @@ fun test(xs) = //│ > let x@52 = $param0@45#1 //│ > $param1@46 is Cons($param0@48, $param1@49) and //│ > let y@53 = $param0@48#1 -//│ > $param1@49 is Nil then builtin:+#83(x@52#666, y@53#666) +//│ > $param1@49 is Nil then builtin:+#88(x@52#666, y@53#666) //│ > $param0@41 is "mul" and $param1@42 is Cons($param0@45, $param1@46) and //│ > let x@47 = $param0@45#0 //│ > $param1@46 is Cons($param0@48, $param1@49) and //│ > let y@50 = $param0@48#0 -//│ > $param1@49 is Nil then builtin:*#23(x@47#666, y@50#666) +//│ > $param1@49 is Nil then builtin:*#26(x@47#666, y@50#666) //│ > $param0@41 is "sum" and //│ > let xs@43 = $param1@42#0 //│ > else globalThis:block#3#666.sum‹member:sum›(0, xs@43#666)