diff --git a/hkmc2/jvm/src/test/scala/hkmc2/BbmlDiffMaker.scala b/hkmc2/jvm/src/test/scala/hkmc2/BbmlDiffMaker.scala index 447f74d71..603147d7d 100644 --- a/hkmc2/jvm/src/test/scala/hkmc2/BbmlDiffMaker.scala +++ b/hkmc2/jvm/src/test/scala/hkmc2/BbmlDiffMaker.scala @@ -21,7 +21,7 @@ abstract class BbmlDiffMaker extends JSBackendDiffMaker: lazy val bbCtx = given Elaborator.Ctx = curCtx - bbml.BbCtx.init(_ => die, curCtx.allMembers) + bbml.BbCtx.init(_ => die) var bbmlTyper: Opt[BBTyper] = None diff --git a/hkmc2/jvm/src/test/scala/hkmc2/DiffMaker.scala b/hkmc2/jvm/src/test/scala/hkmc2/DiffMaker.scala index 62c200132..b93eaa461 100644 --- a/hkmc2/jvm/src/test/scala/hkmc2/DiffMaker.scala +++ b/hkmc2/jvm/src/test/scala/hkmc2/DiffMaker.scala @@ -98,6 +98,7 @@ abstract class DiffMaker: val expectTypeErrors = NullaryCommand("e") val expectRuntimeErrors = NullaryCommand("re") val expectCodeGenErrors = NullaryCommand("ge") + def expectRuntimeOrCodeGenErrors = expectRuntimeErrors.isSet || expectCodeGenErrors.isSet val allowRuntimeErrors = NullaryCommand("allowRuntimeErrors") val expectWarnings = NullaryCommand("w") val showRelativeLineNums = NullaryCommand("showRelativeLineNums") @@ -174,7 +175,7 @@ abstract class DiffMaker: unexpected("runtime error", blockLineNum) case Diagnostic.Source.Runtime => runtimeErrors += 1 - if expectRuntimeErrors.isUnset && !tolerateErrors then + if !expectRuntimeOrCodeGenErrors && !tolerateErrors then failures += globalStartLineNum unexpected("runtime error", blockLineNum) case Diagnostic.Kind.Warning => diff --git a/hkmc2/jvm/src/test/scala/hkmc2/JSBackendDiffMaker.scala b/hkmc2/jvm/src/test/scala/hkmc2/JSBackendDiffMaker.scala index a0722cca9..50f2a7324 100644 --- a/hkmc2/jvm/src/test/scala/hkmc2/JSBackendDiffMaker.scala +++ b/hkmc2/jvm/src/test/scala/hkmc2/JSBackendDiffMaker.scala @@ -62,7 +62,7 @@ abstract class JSBackendDiffMaker extends MLsDiffMaker: output(jsStr) def mkQuery(prefix: Str, jsStr: Str) = val queryStr = jsStr.replaceAll("\n", " ") - val (reply, stderr) = host.query(queryStr, expectRuntimeErrors.isUnset && fixme.isUnset && todo.isUnset) + val (reply, stderr) = host.query(queryStr, !expectRuntimeOrCodeGenErrors && fixme.isUnset && todo.isUnset) reply match case ReplHost.Result(content, stdout) => if silent.isUnset then diff --git a/hkmc2/shared/src/main/scala/hkmc2/bbml/bbML.scala b/hkmc2/shared/src/main/scala/hkmc2/bbml/bbML.scala index 070e39baf..ea48cfe3b 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/bbml/bbML.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/bbml/bbML.scala @@ -61,7 +61,7 @@ object BbCtx: ClassLikeType(ctx.getCls("Region").get, Wildcard(sk, sk) :: Nil) def refTy(ct: Type, sk: Type)(using ctx: BbCtx): Type = ClassLikeType(ctx.getCls("Ref").get, Wildcard(ct, ct) :: Wildcard.out(sk) :: Nil) - def init(raise: Raise, predefs: Map[Str, Symbol])(using Elaborator.State, Elaborator.Ctx): BbCtx = + def init(raise: Raise)(using Elaborator.State, Elaborator.Ctx): BbCtx = new BbCtx(raise, summon, None, 1, HashMap.empty, HashMap.empty, HashMap.empty) end BbCtx diff --git a/hkmc2/shared/src/main/scala/hkmc2/codegen/Lowering.scala b/hkmc2/shared/src/main/scala/hkmc2/codegen/Lowering.scala index f0dbfba52..3a94b8843 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/codegen/Lowering.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/codegen/Lowering.scala @@ -58,35 +58,7 @@ class Lowering(using TL, Raise, Elaborator.State): args => subTerm(a.value)(r => acc(r :: args)) )(Nil) case st.Ref(sym) => - sym match - case sym: BlockMemberSymbol => - // k(subst(Value.Ref(sym.modTree.get.symbol))) - k(subst(Value.Ref(sym))) - case sym: LocalSymbol => - k(subst(Value.Ref(sym))) - case sym: ClassSymbol => - k(subst(Value.Ref(sym))) - case sym: ModuleSymbol => - k(subst(Value.Ref(sym))) - case sym: TopLevelSymbol => - k(subst(Value.Ref(sym))) - /* // * Old logic that auto-lifted `C` ~> `(...) => new C(...)` - case sym: ClassSymbol => // TODO rm - // k(subst(Value.Ref(sym))) - sym.defn match - case N => End("error: class has no declaration") // TODO report? - case S(clsDefn) => - if clsDefn.kind is syntax.Mod then - k(Value.Ref(sym)) - else - val ps = clsDefn.paramsOpt.getOrElse(Nil) - val psSyms = ps.map(p => - p.copy(sym = new VarSymbol(p.sym.id, summon[Elaborator.State].nextUid))) - k(Value.Lam(psSyms, - Return(Instantiate(Value.Ref(sym), - psSyms.map(p => Value.Ref(p.sym))), false))) - */ - // * Perhaps this `new` insertion should also be removed...? + k(subst(Value.Ref(sym))) case st.App(f, arg) => arg match case Tup(fs) => @@ -104,7 +76,6 @@ class Lowering(using TL, Raise, Elaborator.State): rec(as, Nil) case _ => TODO("Other argument list forms") - case st.Blk(Nil, res) => term(res)(k) case st.Blk(Lit(Tree.UnitLit(true)) :: stats, res) => subTerm(st.Blk(stats, res))(k) 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 96c02c0f7..285d4a666 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/codegen/js/JSBuilder.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/codegen/js/JSBuilder.scala @@ -15,6 +15,8 @@ import hkmc2.semantics.InnerSymbol import hkmc2.semantics.ParamList import hkmc2.codegen.Value.Lam import hkmc2.semantics.BlockMemberSymbol +import hkmc2.semantics.BuiltinSymbol +import hkmc2.Message.MessageContext // TODO factor some logic for other codegen backends @@ -43,6 +45,11 @@ class JSBuilder extends CodeBuilder: case Argument case Operand(prec: Int) + def err(errMsg: Message)(using Raise, Scope): Document = + raise(ErrorReport(errMsg -> N :: Nil, + source = Diagnostic.Source.Compilation)) + doc"(()=>{throw globalThis.Error(${result(Value.Lit(syntax.Tree.StrLit(errMsg.show)))})})()" + def getVar(l: Local)(using Raise, Scope): Document = l match case ts: semantics.TermSymbol => ts.owner match @@ -63,34 +70,25 @@ class JSBuilder extends CodeBuilder: def result(r: Result)(using Raise, Scope): Document = r match case Value.This(sym) => summon[Scope].findThis_!(sym) - case Value.Ref(l) => getVar(l) case Value.Lit(Tree.StrLit(value)) => JSBuilder.makeStringLiteral(value) case Value.Lit(lit) => lit.idStr + case Value.Ref(l: BuiltinSymbol) => + if l.nullary then l.nme + else err(msg"Illegal reference to builtin symbol '${l.nme}'") + case Value.Ref(l) => getVar(l) - - // * FIXME: this should be done in the Elaborator - - // case Call(Value.Ref(l: semantics.InnerSymbol), lhs :: rhs :: Nil) if builtinOpsMap contains l.nme => - // case Call(Value.Ref(l), lhs :: rhs :: Nil) if builtinOpsMap contains l.nme => - - case Call(Select(Value.Ref(_: TopLevelSymbol), Tree.Ident(nme)), lhs :: rhs :: Nil) if builtinOpsMap contains nme => - val op = builtinOpsMap(nme) - val res = doc"${result(lhs)} ${op} ${result(rhs)}" - if needsParens(op) then doc"(${res})" else res - case Call(Select(Value.Ref(_: TopLevelSymbol), Tree.Ident(nme)), lhs :: Nil) if builtinOpsMap contains nme => - val op = builtinOpsMap(nme) - val res = doc"${op} ${result(lhs)}" - if needsParens(op) then doc"(${res})" else res - - case Call(Value.Ref(sym: BlockMemberSymbol), lhs :: rhs :: Nil) if builtinOpsMap contains sym.nme => - val op = builtinOpsMap(sym.nme) - val res = doc"${result(lhs)} ${op} ${result(rhs)}" - if needsParens(op) then doc"(${res})" else res - case Call(Value.Ref(sym: BlockMemberSymbol), lhs :: Nil) if builtinOpsMap contains sym.nme => - val op = builtinOpsMap(sym.nme) - val res = doc"${op} ${result(lhs)}" - if needsParens(op) then doc"(${res})" else res - + case Call(Value.Ref(l: BuiltinSymbol), lhs :: rhs :: Nil) => + if l.binary then + val res = doc"${result(lhs)} ${l.nme} ${result(rhs)}" + if needsParens(l.nme) then doc"(${res})" else res + else err(msg"Cannot call non-binary builtin symbol '${l.nme}'") + case Call(Value.Ref(l: BuiltinSymbol), rhs :: Nil) => + if l.unary then + val res = doc"${l.nme} ${result(rhs)}" + if needsParens(l.nme) then doc"(${res})" else res + else err(msg"Cannot call non-unary builtin symbol '${l.nme}'") + case Call(Value.Ref(l: BuiltinSymbol), args) => + err(msg"Illeal arity for builtin symbol '${l.nme}'") case Call(fun, args) => val base = fun match diff --git a/hkmc2/shared/src/main/scala/hkmc2/semantics/Desugarer.scala b/hkmc2/shared/src/main/scala/hkmc2/semantics/Desugarer.scala index 413df1025..122793508 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/semantics/Desugarer.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/semantics/Desugarer.scala @@ -202,13 +202,7 @@ class Desugarer(tl: TraceLogger, elaborator: Elaborator) post = (res: Split) => s"termSplit: after op >>> $res" ): // Resolve the operator. - val opRef = - ctx.get(opName) match - case S(sym) => sym.ref(opIdent) - case N => - raise(ErrorReport(msg"Name not found: $opName" -> tree.toLoc :: Nil)) - Term.Error - .withLocOf(opIdent) + val opRef = term(opIdent) // Elaborate and finish the LHS. Nominate the LHS if necessary. nominate(ctx, finish(term(lhs)(using ctx))): lhsSymbol => // Compose a function that takes the RHS and finishes the application. diff --git a/hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala b/hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala index c3d2b314b..bee794c27 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala @@ -18,6 +18,24 @@ import Keyword.{`let`, `set`} object Elaborator: + val builtinOpsMap: Map[Str, BuiltinSymbol] = + val binOps: Ls[Str] = Ls( + ",", + "+", "-", "*", "/", "%", + "==", "!=", "<", "<=", ">", ">=", + "===", + "&&", "||") + val isUnary: Str => Bool = Set("-", "+", "!", "~").contains + val baseBuiltins = binOps.map: op => + op -> BuiltinSymbol(op, binary = true, unary = isUnary(op), nullary = false) + .toMap + baseBuiltins + + (";" -> baseBuiltins(",")) + + ("+." -> baseBuiltins("+")) + + ("-." -> baseBuiltins("-")) + + ("*." -> baseBuiltins("*")) + val reservedNames = builtinOpsMap.keySet + "NaN" + "Infinity" + case class Ctx(outer: Opt[InnerSymbol], parent: Opt[Ctx], env: Map[Str, Ctx.Elem]): def +(local: Str -> Symbol): Ctx = copy(outer, env = env + local.mapSecond(Ctx.RefElem(_))) def ++(locals: IterableOnce[Str -> Symbol]): Ctx = @@ -171,8 +189,11 @@ extends Importer: ctx.get(name) match case S(sym) => sym.ref(id) case N => - raise(ErrorReport(msg"Name not found: $name" -> tree.toLoc :: Nil)) - Term.Error + builtinOpsMap.get(name) match + case S(bi) => bi.ref(id) + case N => + raise(ErrorReport(msg"Name not found: $name" -> tree.toLoc :: Nil)) + Term.Error case TyApp(lhs, targs) => Term.TyApp(term(lhs), targs.map { case Modified(Keyword.`in`, inLoc, arg) => Term.WildcardTy(S(term(arg)), N) diff --git a/hkmc2/shared/src/main/scala/hkmc2/semantics/Symbol.scala b/hkmc2/shared/src/main/scala/hkmc2/semantics/Symbol.scala index b407d51e7..1b2451b30 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/semantics/Symbol.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/semantics/Symbol.scala @@ -82,6 +82,10 @@ class VarSymbol(val id: Ident, uid: Int) extends BlockLocalSymbol(id.name, uid) val name: Str = id.name // override def toString: Str = s"$name@$uid" +class BuiltinSymbol(val nme: Str, val binary: Bool, val unary: Bool, val nullary: Bool) extends Symbol: + def toLoc: Option[Loc] = N + override def toString: Str = s"builtin:$nme" + /** This is the outside-facing symbol associated to a possibly-overloaded * definition living in a block – e.g., a module or class. */ diff --git a/hkmc2/shared/src/main/scala/hkmc2/semantics/Term.scala b/hkmc2/shared/src/main/scala/hkmc2/semantics/Term.scala index 1da3d70dc..967b3d08d 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/semantics/Term.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/semantics/Term.scala @@ -10,6 +10,7 @@ final case class QuantVar(sym: VarSymbol, ub: Opt[Term], lb: Opt[Term]) enum Term extends Statement: case Error case Lit(lit: Literal) + case Builtin(id: Tree.Ident, nme: Str) case Ref(sym: Symbol)(val tree: Tree.Ident, val refNum: Int) case App(lhs: Term, rhs: Term)(val tree: Tree.App, val resSym: FlowSymbol) case TyApp(lhs: Term, targs: Ls[Term]) @@ -77,7 +78,7 @@ sealed trait Statement extends AutoLocated: case Blk(stats, res) => stats ::: res :: Nil case _ => subTerms def subTerms: Ls[Term] = this match - case Error | _: Lit | _: Ref => Nil + case Error | _: Lit | _: Ref | _: Builtin => Nil case App(lhs, rhs) => lhs :: rhs :: Nil case FunTy(lhs, rhs, eff) => lhs :: rhs :: eff.toList case TyApp(pre, tarsg) => pre :: tarsg diff --git a/hkmc2/shared/src/test/mlscript-compile/Example.mjs b/hkmc2/shared/src/test/mlscript-compile/Example.mjs index 0cd6e077c..db49bdc05 100644 --- a/hkmc2/shared/src/test/mlscript-compile/Example.mjs +++ b/hkmc2/shared/src/test/mlscript-compile/Example.mjs @@ -1,14 +1,11 @@ import "./Predef.mjs"; -class Int { - constructor() { - - } - toString() { return "Int"; } -}; const Example$class = class Example { constructor() { } + funnySlash(f, arg) { + return f(arg) + } inc(x) { return x + 1 } diff --git a/hkmc2/shared/src/test/mlscript-compile/Example.mls b/hkmc2/shared/src/test/mlscript-compile/Example.mls index c411d88da..bdaa9c9f9 100644 --- a/hkmc2/shared/src/test/mlscript-compile/Example.mls +++ b/hkmc2/shared/src/test/mlscript-compile/Example.mls @@ -3,14 +3,11 @@ import "./Predef.mls" open Predef -class Int - -fun (+): (Int, Int) -> Int - - module Example with ... +fun (/) funnySlash(f, arg) = f(arg) + fun inc(x) = x + 1 diff --git a/hkmc2/shared/src/test/mlscript/bbml/bbBasics.mls b/hkmc2/shared/src/test/mlscript/bbml/bbBasics.mls index 5ed5d5e69..fae2a4594 100644 --- a/hkmc2/shared/src/test/mlscript/bbml/bbBasics.mls +++ b/hkmc2/shared/src/test/mlscript/bbml/bbBasics.mls @@ -207,11 +207,11 @@ class Pair[A, B](fst: A, snd: B) :fixme if 1 < 2 then 1 else 0 -//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref($scrut@130),LitPat(BoolLit(true)),Else(Lit(IntLit(1)))),Else(Lit(IntLit(0)))) (of class hkmc2.semantics.Split$Cons) +//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref($scrut@112),LitPat(BoolLit(true)),Else(Lit(IntLit(1)))),Else(Lit(IntLit(0)))) (of class hkmc2.semantics.Split$Cons) :fixme if false then 1 else "1" -//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref($scrut@132),LitPat(BoolLit(true)),Else(Lit(IntLit(1)))),Else(Lit(StrLit(1)))) (of class hkmc2.semantics.Split$Cons) +//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref($scrut@114),LitPat(BoolLit(true)),Else(Lit(IntLit(1)))),Else(Lit(StrLit(1)))) (of class hkmc2.semantics.Split$Cons) if 1 is Int then 1 else 0 @@ -240,7 +240,7 @@ test("1") :fixme fun fact(n) = if n > 1 then n * fact(n - 1) else 1 -//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref($scrut@146),LitPat(BoolLit(true)),Else(App(Sel(Ref(globalThis:import#bbPredef),Ident(*)),Tup(List(Fld(‹›,Ref(n@144),None), Fld(‹›,App(Sel(Ref(globalThis:block#49),Ident(fact)),Tup(List(Fld(‹›,App(Sel(Ref(globalThis:import#bbPredef),Ident(-)),Tup(List(Fld(‹›,Ref(n@144),None), Fld(‹›,Lit(IntLit(1)),None)))),None)))),None)))))),Else(Lit(IntLit(1)))) (of class hkmc2.semantics.Split$Cons) +//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref($scrut@128),LitPat(BoolLit(true)),Else(App(Sel(Ref(globalThis:import#bbPredef),Ident(*)),Tup(List(Fld(‹›,Ref(n@126),None), Fld(‹›,App(Sel(Ref(globalThis:block#49),Ident(fact)),Tup(List(Fld(‹›,App(Sel(Ref(globalThis:import#bbPredef),Ident(-)),Tup(List(Fld(‹›,Ref(n@126),None), Fld(‹›,Lit(IntLit(1)),None)))),None)))),None)))))),Else(Lit(IntLit(1)))) (of class hkmc2.semantics.Split$Cons) fact //│ Type: ⊥ @@ -253,7 +253,7 @@ fact(1) fun fact2 = case 0 then 1 n then n * fact2(n - 1) -//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref(caseScrut@155),LitPat(IntLit(0)),Else(Lit(IntLit(1)))),Let(n@156,Ref(caseScrut@155),Else(App(Sel(Ref(globalThis:import#bbPredef),Ident(*)),Tup(List(Fld(‹›,Ref(n@156),None), Fld(‹›,App(Sel(Ref(globalThis:block#52),Ident(fact2)),Tup(List(Fld(‹›,App(Sel(Ref(globalThis:import#bbPredef),Ident(-)),Tup(List(Fld(‹›,Ref(n@156),None), Fld(‹›,Lit(IntLit(1)),None)))),None)))),None))))))) (of class hkmc2.semantics.Split$Cons) +//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref(caseScrut@137),LitPat(IntLit(0)),Else(Lit(IntLit(1)))),Let(n@138,Ref(caseScrut@137),Else(App(Sel(Ref(globalThis:import#bbPredef),Ident(*)),Tup(List(Fld(‹›,Ref(n@138),None), Fld(‹›,App(Sel(Ref(globalThis:block#52),Ident(fact2)),Tup(List(Fld(‹›,App(Sel(Ref(globalThis:import#bbPredef),Ident(-)),Tup(List(Fld(‹›,Ref(n@138),None), Fld(‹›,Lit(IntLit(1)),None)))),None)))),None))))))) (of class hkmc2.semantics.Split$Cons) fact2 //│ Type: ⊥ diff --git a/hkmc2/shared/src/test/mlscript/bbml/bbBorrowing.mls b/hkmc2/shared/src/test/mlscript/bbml/bbBorrowing.mls index 5f143e035..681c3f5af 100644 --- a/hkmc2/shared/src/test/mlscript/bbml/bbBorrowing.mls +++ b/hkmc2/shared/src/test/mlscript/bbml/bbBorrowing.mls @@ -61,7 +61,7 @@ letreg of r => 123 if next(it) > 0 then () => 0 else () => clear(b) k() -//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref($scrut@120),LitPat(BoolLit(true)),Else(Lam(List(),Lit(IntLit(0))))),Else(Lam(List(),App(Sel(Ref(globalThis:block#5),Ident(clear)),Tup(List(Fld(‹›,Ref(b@109),None))))))) (of class hkmc2.semantics.Split$Cons) +//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref($scrut@102),LitPat(BoolLit(true)),Else(Lam(List(),Lit(IntLit(0))))),Else(Lam(List(),App(Sel(Ref(globalThis:block#5),Ident(clear)),Tup(List(Fld(‹›,Ref(b@91),None))))))) (of class hkmc2.semantics.Split$Cons) :e letreg of r => diff --git a/hkmc2/shared/src/test/mlscript/bbml/bbCheck.mls b/hkmc2/shared/src/test/mlscript/bbml/bbCheck.mls index ea3c81e8b..66d782c49 100644 --- a/hkmc2/shared/src/test/mlscript/bbml/bbCheck.mls +++ b/hkmc2/shared/src/test/mlscript/bbml/bbCheck.mls @@ -103,7 +103,7 @@ high(x => x + 1) :fixme (if false then x => x else y => y): [A] -> A -> A -//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref($scrut@105),LitPat(BoolLit(true)),Else(Lam(List(Param(‹›,x@106,None)),Ref(x@106)))),Else(Lam(List(Param(‹›,y@104,None)),Ref(y@104)))) (of class hkmc2.semantics.Split$Cons) +//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref($scrut@87),LitPat(BoolLit(true)),Else(Lam(List(Param(‹›,x@88,None)),Ref(x@88)))),Else(Lam(List(Param(‹›,y@86,None)),Ref(y@86)))) (of class hkmc2.semantics.Split$Cons) fun baz: Int -> (([A] -> A -> A), Int) -> Int diff --git a/hkmc2/shared/src/test/mlscript/bbml/bbGPCE.mls b/hkmc2/shared/src/test/mlscript/bbml/bbGPCE.mls index ecc2e039b..05cc5dad3 100644 --- a/hkmc2/shared/src/test/mlscript/bbml/bbGPCE.mls +++ b/hkmc2/shared/src/test/mlscript/bbml/bbGPCE.mls @@ -7,7 +7,7 @@ fun power(x) = case 0 then `1.0 n then x `*. power(x)(n - 1) power -//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref(caseScrut@51),LitPat(IntLit(0)),Else(Quoted(Lit(DecLit(1.0))))),Let(n@52,Ref(caseScrut@51),Else(Quoted(App(Sel(Ref(globalThis:import#Prelude),Ident(*.)),Tup(List(Fld(‹›,Unquoted(Ref(x@50)),None), Fld(‹›,Unquoted(App(App(Sel(Ref(globalThis:block#0),Ident(power)),Tup(List(Fld(‹›,Ref(x@50),None)))),Tup(List(Fld(‹›,App(Sel(Ref(globalThis:import#bbPredef),Ident(-)),Tup(List(Fld(‹›,Ref(n@52),None), Fld(‹›,Lit(IntLit(1)),None)))),None))))),None)))))))) (of class hkmc2.semantics.Split$Cons) +//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref(caseScrut@33),LitPat(IntLit(0)),Else(Quoted(Lit(DecLit(1.0))))),Let(n@34,Ref(caseScrut@33),Else(Quoted(App(Ref(builtin:*),Tup(List(Fld(‹›,Unquoted(Ref(x@32)),None), Fld(‹›,Unquoted(App(App(Sel(Ref(globalThis:block#0),Ident(power)),Tup(List(Fld(‹›,Ref(x@32),None)))),Tup(List(Fld(‹›,App(Sel(Ref(globalThis:import#bbPredef),Ident(-)),Tup(List(Fld(‹›,Ref(n@34),None), Fld(‹›,Lit(IntLit(1)),None)))),None))))),None)))))))) (of class hkmc2.semantics.Split$Cons) fun id: [A] -> A -> A @@ -53,7 +53,7 @@ fun body(x, y) = case fun gib_naive(n) = (x, y) `=> body(x, y)(n) let gn5 = run(gib_naive(5)) -//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref(caseScrut@97),LitPat(IntLit(0)),Else(Ref(x@95))),Cons(Branch(Ref(caseScrut@97),LitPat(IntLit(1)),Else(Ref(y@96))),Let(n@98,Ref(caseScrut@97),Else(App(App(Sel(Ref(globalThis:block#7),Ident(body)),Tup(List(Fld(‹›,Ref(y@96),None), Fld(‹›,Quoted(App(Sel(Ref(globalThis:import#bbPredef),Ident(+)),Tup(List(Fld(‹›,Unquoted(Ref(x@95)),None), Fld(‹›,Unquoted(Ref(y@96)),None))))),None)))),Tup(List(Fld(‹›,App(Sel(Ref(globalThis:import#bbPredef),Ident(-)),Tup(List(Fld(‹›,Ref(n@98),None), Fld(‹›,Lit(IntLit(1)),None)))),None)))))))) (of class hkmc2.semantics.Split$Cons) +//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref(caseScrut@79),LitPat(IntLit(0)),Else(Ref(x@77))),Cons(Branch(Ref(caseScrut@79),LitPat(IntLit(1)),Else(Ref(y@78))),Let(n@80,Ref(caseScrut@79),Else(App(App(Sel(Ref(globalThis:block#7),Ident(body)),Tup(List(Fld(‹›,Ref(y@78),None), Fld(‹›,Quoted(App(Sel(Ref(globalThis:import#bbPredef),Ident(+)),Tup(List(Fld(‹›,Unquoted(Ref(x@77)),None), Fld(‹›,Unquoted(Ref(y@78)),None))))),None)))),Tup(List(Fld(‹›,App(Sel(Ref(globalThis:import#bbPredef),Ident(-)),Tup(List(Fld(‹›,Ref(n@80),None), Fld(‹›,Lit(IntLit(1)),None)))),None)))))))) (of class hkmc2.semantics.Split$Cons) fun bind(rhs, k) = `let x = rhs `in k(x) bind @@ -66,7 +66,7 @@ fun body(x, y) = case 0 then x 1 then y n then bind of x `+ y, (z => body(y, z)(n - 1)): [C] -> CodeBase[out Int, out C, out Any] -> CodeBase[out C, out Any] -//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref(caseScrut@125),LitPat(IntLit(0)),Else(Ref(x@123))),Cons(Branch(Ref(caseScrut@125),LitPat(IntLit(1)),Else(Ref(y@124))),Let(n@126,Ref(caseScrut@125),Else(App(Sel(Ref(globalThis:block#8),Ident(bind)),Tup(List(Fld(‹›,Quoted(App(Sel(Ref(globalThis:import#bbPredef),Ident(+)),Tup(List(Fld(‹›,Unquoted(Ref(x@123)),None), Fld(‹›,Unquoted(Ref(y@124)),None))))),None), Fld(‹›,Lam(List(Param(‹›,z@129,None)),App(App(Sel(Ref(globalThis:block#9),Ident(body)),Tup(List(Fld(‹›,Ref(y@124),None), Fld(‹›,Ref(z@129),None)))),Tup(List(Fld(‹›,App(Sel(Ref(globalThis:import#bbPredef),Ident(-)),Tup(List(Fld(‹›,Ref(n@126),None), Fld(‹›,Lit(IntLit(1)),None)))),None))))),Some(Forall(List(QuantVar(C@133,None,None)),FunTy(Tup(List(Fld(‹›,TyApp(Sel(Ref(globalThis:import#bbPredef),Ident(CodeBase)),List(WildcardTy(None,Some(Sel(Ref(globalThis:import#Prelude),Ident(Int)))), WildcardTy(None,Some(Ref(C@133))), WildcardTy(None,Some(Sel(Ref(globalThis:import#Prelude),Ident(Any)))))),None))),TyApp(Sel(Ref(globalThis:import#bbPredef),Ident(CodeBase)),List(WildcardTy(None,Some(Ref(C@133))), WildcardTy(None,Some(Sel(Ref(globalThis:import#Prelude),Ident(Any)))))),None))))))))))) (of class hkmc2.semantics.Split$Cons) +//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref(caseScrut@107),LitPat(IntLit(0)),Else(Ref(x@105))),Cons(Branch(Ref(caseScrut@107),LitPat(IntLit(1)),Else(Ref(y@106))),Let(n@108,Ref(caseScrut@107),Else(App(Sel(Ref(globalThis:block#8),Ident(bind)),Tup(List(Fld(‹›,Quoted(App(Sel(Ref(globalThis:import#bbPredef),Ident(+)),Tup(List(Fld(‹›,Unquoted(Ref(x@105)),None), Fld(‹›,Unquoted(Ref(y@106)),None))))),None), Fld(‹›,Lam(List(Param(‹›,z@111,None)),App(App(Sel(Ref(globalThis:block#9),Ident(body)),Tup(List(Fld(‹›,Ref(y@106),None), Fld(‹›,Ref(z@111),None)))),Tup(List(Fld(‹›,App(Sel(Ref(globalThis:import#bbPredef),Ident(-)),Tup(List(Fld(‹›,Ref(n@108),None), Fld(‹›,Lit(IntLit(1)),None)))),None))))),Some(Forall(List(QuantVar(C@115,None,None)),FunTy(Tup(List(Fld(‹›,TyApp(Sel(Ref(globalThis:import#bbPredef),Ident(CodeBase)),List(WildcardTy(None,Some(Sel(Ref(globalThis:import#Prelude),Ident(Int)))), WildcardTy(None,Some(Ref(C@115))), WildcardTy(None,Some(Sel(Ref(globalThis:import#Prelude),Ident(Any)))))),None))),TyApp(Sel(Ref(globalThis:import#bbPredef),Ident(CodeBase)),List(WildcardTy(None,Some(Ref(C@115))), WildcardTy(None,Some(Sel(Ref(globalThis:import#Prelude),Ident(Any)))))),None))))))))))) (of class hkmc2.semantics.Split$Cons) fun bind: [G] -> (CodeBase[out Int, out G, out Any], [C] -> CodeBase[out Int, out C, out Any] -> CodeBase[out Int, out C | G, out Any]) -> CodeBase[out Int, out G, out Any] fun bind(rhs, k) = `let x = rhs `in k(x) @@ -81,7 +81,7 @@ fun body(x, y) = case 1 then y n then bind of x `+ y, (z => body(y, z)(n - 1)): [C] -> CodeBase[out Int, out C, out Any] -> CodeBase[out Int, out C, out Any] body -//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref(caseScrut@152),LitPat(IntLit(0)),Else(Ref(x@150))),Cons(Branch(Ref(caseScrut@152),LitPat(IntLit(1)),Else(Ref(y@151))),Let(n@153,Ref(caseScrut@152),Else(App(Sel(Ref(globalThis:block#10),Ident(bind)),Tup(List(Fld(‹›,Quoted(App(Sel(Ref(globalThis:import#bbPredef),Ident(+)),Tup(List(Fld(‹›,Unquoted(Ref(x@150)),None), Fld(‹›,Unquoted(Ref(y@151)),None))))),None), Fld(‹›,Lam(List(Param(‹›,z@156,None)),App(App(Sel(Ref(globalThis:block#11),Ident(body)),Tup(List(Fld(‹›,Ref(y@151),None), Fld(‹›,Ref(z@156),None)))),Tup(List(Fld(‹›,App(Sel(Ref(globalThis:import#bbPredef),Ident(-)),Tup(List(Fld(‹›,Ref(n@153),None), Fld(‹›,Lit(IntLit(1)),None)))),None))))),Some(Forall(List(QuantVar(C@160,None,None)),FunTy(Tup(List(Fld(‹›,TyApp(Sel(Ref(globalThis:import#bbPredef),Ident(CodeBase)),List(WildcardTy(None,Some(Sel(Ref(globalThis:import#Prelude),Ident(Int)))), WildcardTy(None,Some(Ref(C@160))), WildcardTy(None,Some(Sel(Ref(globalThis:import#Prelude),Ident(Any)))))),None))),TyApp(Sel(Ref(globalThis:import#bbPredef),Ident(CodeBase)),List(WildcardTy(None,Some(Sel(Ref(globalThis:import#Prelude),Ident(Int)))), WildcardTy(None,Some(Ref(C@160))), WildcardTy(None,Some(Sel(Ref(globalThis:import#Prelude),Ident(Any)))))),None))))))))))) (of class hkmc2.semantics.Split$Cons) +//│ /!!!\ Uncaught error: scala.MatchError: Cons(Branch(Ref(caseScrut@134),LitPat(IntLit(0)),Else(Ref(x@132))),Cons(Branch(Ref(caseScrut@134),LitPat(IntLit(1)),Else(Ref(y@133))),Let(n@135,Ref(caseScrut@134),Else(App(Sel(Ref(globalThis:block#10),Ident(bind)),Tup(List(Fld(‹›,Quoted(App(Sel(Ref(globalThis:import#bbPredef),Ident(+)),Tup(List(Fld(‹›,Unquoted(Ref(x@132)),None), Fld(‹›,Unquoted(Ref(y@133)),None))))),None), Fld(‹›,Lam(List(Param(‹›,z@138,None)),App(App(Sel(Ref(globalThis:block#11),Ident(body)),Tup(List(Fld(‹›,Ref(y@133),None), Fld(‹›,Ref(z@138),None)))),Tup(List(Fld(‹›,App(Sel(Ref(globalThis:import#bbPredef),Ident(-)),Tup(List(Fld(‹›,Ref(n@135),None), Fld(‹›,Lit(IntLit(1)),None)))),None))))),Some(Forall(List(QuantVar(C@142,None,None)),FunTy(Tup(List(Fld(‹›,TyApp(Sel(Ref(globalThis:import#bbPredef),Ident(CodeBase)),List(WildcardTy(None,Some(Sel(Ref(globalThis:import#Prelude),Ident(Int)))), WildcardTy(None,Some(Ref(C@142))), WildcardTy(None,Some(Sel(Ref(globalThis:import#Prelude),Ident(Any)))))),None))),TyApp(Sel(Ref(globalThis:import#bbPredef),Ident(CodeBase)),List(WildcardTy(None,Some(Sel(Ref(globalThis:import#Prelude),Ident(Int)))), WildcardTy(None,Some(Ref(C@142))), WildcardTy(None,Some(Sel(Ref(globalThis:import#Prelude),Ident(Any)))))),None))))))))))) (of class hkmc2.semantics.Split$Cons) fun gib(n) = (x, y) `=> body(x, y)(n) let g5 = run(gib(5)) diff --git a/hkmc2/shared/src/test/mlscript/bbml/bbRec.mls b/hkmc2/shared/src/test/mlscript/bbml/bbRec.mls index dad96205c..14ff893ae 100644 --- a/hkmc2/shared/src/test/mlscript/bbml/bbRec.mls +++ b/hkmc2/shared/src/test/mlscript/bbml/bbRec.mls @@ -19,7 +19,7 @@ f :todo fun f(x) = f(x.a) -//│ ╔══[ERROR] Term shape not yet supported by BbML: Sel(Ref(x@57),Ident(a)) +//│ ╔══[ERROR] Term shape not yet supported by BbML: Sel(Ref(x@39),Ident(a)) //│ ║ l.21: fun f(x) = f(x.a) //│ ╙── ^ //│ Type: ⊤ diff --git a/hkmc2/shared/src/test/mlscript/bbml/bbTODOs.mls b/hkmc2/shared/src/test/mlscript/bbml/bbTODOs.mls index 2081dad30..8f0b8cf32 100644 --- a/hkmc2/shared/src/test/mlscript/bbml/bbTODOs.mls +++ b/hkmc2/shared/src/test/mlscript/bbml/bbTODOs.mls @@ -24,6 +24,6 @@ fun id: [A] -> A -> A => x = x //│ ╔══[ERROR] Name not found: x //│ ║ l.20: fun id: [A] -> A -> A => x = x //│ ╙── ^ -//│ /!!!\ Uncaught error: scala.MatchError: Lam(List(Param(‹›,A@55,None)),Error) (of class hkmc2.semantics.Term$Lam) +//│ /!!!\ Uncaught error: scala.MatchError: Lam(List(Param(‹›,A@37,None)),Error) (of class hkmc2.semantics.Term$Lam) diff --git a/hkmc2/shared/src/test/mlscript/codegen/BadNew.mls b/hkmc2/shared/src/test/mlscript/codegen/BadNew.mls index df803d799..1b592c1c3 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/BadNew.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/BadNew.mls @@ -12,11 +12,12 @@ new 2 //│ ═══[RUNTIME ERROR] TypeError: 2 is not a constructor :sjs -:re +:ge new 2 + 2 +//│ ═══[COMPILATION ERROR] Illegal reference to builtin symbol '+' //│ JS: -//│ new this["+"].class(2, 2) -//│ ═══[RUNTIME ERROR] TypeError: Cannot read properties of undefined (reading 'class') +//│ new (()=>{throw globalThis.Error("Illegal reference to builtin symbol '+'")})()(2, 2) +//│ ═══[RUNTIME ERROR] TypeError: (intermediate value) is not a constructor :re new() @@ -25,14 +26,14 @@ new() :pe new {} //│ ╔══[PARSE ERROR] Expected expression after `new` keyword; found end of block instead -//│ ║ l.26: new {} +//│ ║ l.27: new {} //│ ╙── ^^ // FIXME the error... :todo new { x = 1 } //│ ╔══[ERROR] Wrong number of type arguments -//│ ║ l.33: new { x = 1 } +//│ ║ l.34: new { x = 1 } //│ ╙── ^ diff --git a/hkmc2/shared/src/test/mlscript/codegen/BasicTerms.mls b/hkmc2/shared/src/test/mlscript/codegen/BasicTerms.mls index 05ddcd7f4..00a7a3f25 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/BasicTerms.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/BasicTerms.mls @@ -41,7 +41,7 @@ log("Hi") //│ Program: //│ imports = Nil //│ main = Assign: -//│ lhs = $tmp@36 +//│ lhs = $tmp@18 //│ rhs = Call: //│ fun = Select: //│ qual = Ref of globalThis:import#Prelude diff --git a/hkmc2/shared/src/test/mlscript/codegen/BuiltinOps.mls b/hkmc2/shared/src/test/mlscript/codegen/BuiltinOps.mls new file mode 100644 index 000000000..ce5ec9e06 --- /dev/null +++ b/hkmc2/shared/src/test/mlscript/codegen/BuiltinOps.mls @@ -0,0 +1,31 @@ +:js + + +:sjs +2 + 2 +//│ JS: +//│ 2 + 2 +//│ = 4 + +:sjs +2 +. 2 +//│ JS: +//│ 2 + 2 +//│ = 4 + +:sjs ++2 +//│ JS: +//│ + 2 +//│ = 2 + + +fun (+) lol(a, b) = [a, b] + +:sjs +1 + 2 +//│ JS: +//│ this.lol(1, 2) +//│ = [ 1, 2 ] + + diff --git a/hkmc2/shared/src/test/mlscript/codegen/ImportExample.mls b/hkmc2/shared/src/test/mlscript/codegen/ImportExample.mls index 9400cbca7..38ee66151 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/ImportExample.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/ImportExample.mls @@ -8,3 +8,35 @@ Example.inc(123) //│ = 124 +Example.funnySlash(Example.inc, 123) +//│ = 124 + + +let n = 42 +//│ n = 42 + +:sjs +n / 2 +//│ JS: +//│ this.n / 2 +//│ = 21 + + +// * Builtin operators can be shadowed/rebound + +open Example + +:sjs +inc / 2 +//│ JS: +//│ Example.funnySlash(Example.inc, 2) +//│ = 3 + +:sjs +:re +n / 2 +//│ JS: +//│ Example.funnySlash(this.n, 2) +//│ ═══[RUNTIME ERROR] TypeError: f is not a function + + diff --git a/hkmc2/shared/src/test/mlscript/codegen/While.mls b/hkmc2/shared/src/test/mlscript/codegen/While.mls index 5cf1872af..0e00ce400 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/While.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/While.mls @@ -158,10 +158,10 @@ if x else 42 //│ Normalized: //│ > if -//│ > let $scrut@134 = globalThis:block#7.x#666 -//│ > $scrut@134 is true and -//│ > let $scrut@135 = globalThis:block#7.y#666 -//│ > $scrut@135 is true then 0 +//│ > let $scrut@116 = globalThis:block#7.x#666 +//│ > $scrut@116 is true and +//│ > let $scrut@117 = globalThis:block#7.y#666 +//│ > $scrut@117 is true then 0 //│ > else 1 //│ > else 42 //│ = 42 @@ -174,10 +174,10 @@ if x else 42 //│ Normalized: //│ > if -//│ > let $scrut@137 = globalThis:block#7.x#666 -//│ > $scrut@137 is true and -//│ > let $scrut@138 = globalThis:block#7.y#666 -//│ > $scrut@138 is true then 0 +//│ > let $scrut@119 = globalThis:block#7.x#666 +//│ > $scrut@119 is true and +//│ > let $scrut@120 = globalThis:block#7.y#666 +//│ > $scrut@120 is true then 0 //│ > else 1 //│ > else 42 //│ = 42 diff --git a/hkmc2/shared/src/test/mlscript/decls/Prelude.mls b/hkmc2/shared/src/test/mlscript/decls/Prelude.mls index 94bd2f803..fc4f816ba 100644 --- a/hkmc2/shared/src/test/mlscript/decls/Prelude.mls +++ b/hkmc2/shared/src/test/mlscript/decls/Prelude.mls @@ -19,27 +19,7 @@ declare val process declare val fs -fun (;): [A] -> ((), A) -> A - -fun (+): (Int, Int) -> Int -fun (-): (Int, Int) -> Int -fun (*): (Int, Int) -> Int -fun (/): (Int, Int) -> Num -fun (<): (Int, Int) -> Bool -fun (>): (Int, Int) -> Bool -fun (<=): (Int, Int) -> Bool -fun (>=): (Int, Int) -> Bool -fun (&&): (Bool, Bool) -> Bool -fun (||): (Bool, Bool) -> Bool - -fun (+.): (Num, Num) -> Num -fun (-.): (Num, Num) -> Num -fun (*.): (Num, Num) -> Num -fun (/.): (Num, Num) -> Num - -// [CY:] poly is not supported here -fun (==): (Any, Any) -> Bool -fun (===): (Any, Any) -> Bool +// TODO: rm fun log: (Any) -> () diff --git a/hkmc2/shared/src/test/mlscript/parser/PrefixOps.mls b/hkmc2/shared/src/test/mlscript/parser/PrefixOps.mls index ec5e1ce96..7c93263dd 100644 --- a/hkmc2/shared/src/test/mlscript/parser/PrefixOps.mls +++ b/hkmc2/shared/src/test/mlscript/parser/PrefixOps.mls @@ -24,34 +24,46 @@ :w :pe +:ge 1 * 2 * 3 //│ ╔══[PARSE ERROR] Expected end of input; found literal instead -//│ ║ l.28: * 2 +//│ ║ l.29: * 2 //│ ╙── ^ //│ ╔══[WARNING] Pure expression in statement position -//│ ║ l.27: 1 +//│ ║ l.28: 1 //│ ╙── ^ +//│ ═══[COMPILATION ERROR] Illegal reference to builtin symbol '*' +//│ ═══[RUNTIME ERROR] Error: Illegal reference to builtin symbol '*' :sjs +:ge + +//│ ═══[COMPILATION ERROR] Illegal reference to builtin symbol '+' //│ JS: -//│ this["+"] +//│ (()=>{throw globalThis.Error("Illegal reference to builtin symbol '+'")})() +//│ ═══[RUNTIME ERROR] Error: Illegal reference to builtin symbol '+' +:ge * +//│ ═══[COMPILATION ERROR] Illegal reference to builtin symbol '*' +//│ ═══[RUNTIME ERROR] Error: Illegal reference to builtin symbol '*' :w :pt +:ge 1 * //│ Parsed tree: //│ IntLit of 1 //│ Ident of "*" //│ ╔══[WARNING] Pure expression in statement position -//│ ║ l.47: 1 +//│ ║ l.57: 1 //│ ╙── ^ +//│ ═══[COMPILATION ERROR] Illegal reference to builtin symbol '*' +//│ ═══[RUNTIME ERROR] Error: Illegal reference to builtin symbol '*' fun (??) foo(x, y) = x + y @@ -78,7 +90,7 @@ fun (??) foo(x, y) = x + y :pe ?? 1 //│ ╔══[PARSE ERROR] Expected end of input; found literal instead -//│ ║ l.79: ?? 1 +//│ ║ l.91: ?? 1 //│ ╙── ^ //│ = [Function: foo] @@ -87,10 +99,10 @@ fun (??) foo(x, y) = x + y 1 ?? 2 //│ ╔══[PARSE ERROR] Expected end of input; found literal instead -//│ ║ l.88: ?? 2 -//│ ╙── ^ +//│ ║ l.100: ?? 2 +//│ ╙── ^ //│ ╔══[WARNING] Pure expression in statement position -//│ ║ l.87: 1 +//│ ║ l.99: 1 //│ ╙── ^ //│ = [Function: foo] diff --git a/hkmc2/shared/src/test/mlscript/ucs/general/CardSuits.mls b/hkmc2/shared/src/test/mlscript/ucs/general/CardSuits.mls index ddb40738f..afa4ec277 100644 --- a/hkmc2/shared/src/test/mlscript/ucs/general/CardSuits.mls +++ b/hkmc2/shared/src/test/mlscript/ucs/general/CardSuits.mls @@ -22,18 +22,18 @@ fun foo(x) = if x is else 4 //│ Desugared: //│ > if -//│ > x@40 is Card($param0@41) $param0@41 is Heart then 0 -//│ > x@40 is Card($param0@41) $param0@41 is Diamond then 1 -//│ > x@40 is Card($param0@41) $param0@41 is Spade then 2 -//│ > x@40 is Card($param0@41) $param0@41 is Club then 3 +//│ > x@22 is Card($param0@23) $param0@23 is Heart then 0 +//│ > x@22 is Card($param0@23) $param0@23 is Diamond then 1 +//│ > x@22 is Card($param0@23) $param0@23 is Spade then 2 +//│ > x@22 is Card($param0@23) $param0@23 is Club then 3 //│ > else 4 //│ Normalized: //│ > if -//│ > x@40 is Card($param0@41) and -//│ > $param0@41 is Heart then 0 -//│ > $param0@41 is Diamond then 1 -//│ > $param0@41 is Spade then 2 -//│ > $param0@41 is Club then 3 +//│ > x@22 is Card($param0@23) and +//│ > $param0@23 is Heart then 0 +//│ > $param0@23 is Diamond then 1 +//│ > $param0@23 is Spade then 2 +//│ > $param0@23 is Club then 3 //│ > else 4 //│ > else 4 diff --git a/hkmc2/shared/src/test/mlscript/ucs/hygiene/PatVars.mls b/hkmc2/shared/src/test/mlscript/ucs/hygiene/PatVars.mls index 80a7b931e..542550815 100644 --- a/hkmc2/shared/src/test/mlscript/ucs/hygiene/PatVars.mls +++ b/hkmc2/shared/src/test/mlscript/ucs/hygiene/PatVars.mls @@ -7,8 +7,8 @@ if 0 is x then 12 //│ Desugared: //│ > if -//│ > let $scrut@29 = 0 -//│ > let x@30 = $scrut@29#0 +//│ > let $scrut@11 = 0 +//│ > let x@12 = $scrut@11#0 //│ > else 12 //│ = 12 diff --git a/hkmc2/shared/src/test/mlscript/ucs/normalization/OverlapOfPrimitives.mls b/hkmc2/shared/src/test/mlscript/ucs/normalization/OverlapOfPrimitives.mls index 7e37adde4..fed495613 100644 --- a/hkmc2/shared/src/test/mlscript/ucs/normalization/OverlapOfPrimitives.mls +++ b/hkmc2/shared/src/test/mlscript/ucs/normalization/OverlapOfPrimitives.mls @@ -6,10 +6,10 @@ fun test(x, p) = if x is else "qax" //│ Desugared: //│ > if -//│ > x@29 is Int and -//│ > let $scrut@32 = p@30#666(x@29#666) -//│ > $scrut@32 is true then "foo" -//│ > x@29 is 0 then "bar" +//│ > x@11 is Int and +//│ > let $scrut@14 = p@12#666(x@11#666) +//│ > $scrut@14 is true then "foo" +//│ > x@11 is 0 then "bar" //│ > else "qax" fun test(x, p) = if x is @@ -18,10 +18,10 @@ fun test(x, p) = if x is else "qax" //│ Desugared: //│ > if -//│ > x@35 is Str and -//│ > let $scrut@38 = p@36#666(x@35#666) -//│ > $scrut@38 is true then "foo" -//│ > x@35 is "lol" then "bar" +//│ > x@17 is Str and +//│ > let $scrut@20 = p@18#666(x@17#666) +//│ > $scrut@20 is true then "foo" +//│ > x@17 is "lol" then "bar" //│ > else "qax" test(0, _ => true) @@ -34,11 +34,11 @@ fun test(x, p) = if x is else "other" //│ Desugared: //│ > if -//│ > x@44 is Num and -//│ > let $scrut@47 = p@45#666(x@44#666) -//│ > $scrut@47 is true then "great" -//│ > x@44 is 2.71828 then "E" -//│ > x@44 is 3.14159 then "PI" +//│ > x@26 is Num and +//│ > let $scrut@29 = p@27#666(x@26#666) +//│ > $scrut@29 is true then "great" +//│ > x@26 is 2.71828 then "E" +//│ > x@26 is 3.14159 then "PI" //│ > else "other" fun test(x, p) = if x is @@ -47,11 +47,11 @@ fun test(x, p) = if x is false then "true" //│ Desugared: //│ > if -//│ > x@50 is Bool and -//│ > let $scrut@53 = p@51#666(x@50#666) -//│ > $scrut@53 is true then "great" -//│ > x@50 is true then "false" -//│ > x@50 is false then "true" +//│ > x@32 is Bool and +//│ > let $scrut@35 = p@33#666(x@32#666) +//│ > $scrut@35 is true then "great" +//│ > x@32 is true then "false" +//│ > x@32 is false then "true" fun test(x, p) = if x is Object and p(x) then "great" @@ -60,11 +60,11 @@ fun test(x, p) = if x is false then "true" //│ Desugared: //│ > if -//│ > x@56 is Object and -//│ > let $scrut@61 = p@57#666(x@56#666) -//│ > $scrut@61 is true then "great" -//│ > x@56 is Bool and -//│ > let $scrut@59 = p@57#666(x@56#666) -//│ > $scrut@59 is true then "great, again" -//│ > x@56 is true then "false" -//│ > x@56 is false then "true" +//│ > x@38 is Object and +//│ > let $scrut@43 = p@39#666(x@38#666) +//│ > $scrut@43 is true then "great" +//│ > x@38 is Bool and +//│ > let $scrut@41 = p@39#666(x@38#666) +//│ > $scrut@41 is true then "great, again" +//│ > x@38 is true then "false" +//│ > x@38 is false then "true" diff --git a/hkmc2/shared/src/test/mlscript/ucs/normalization/UnifySubScrutinees.mls b/hkmc2/shared/src/test/mlscript/ucs/normalization/UnifySubScrutinees.mls index 1cd2537a3..80df3d0ae 100644 --- a/hkmc2/shared/src/test/mlscript/ucs/normalization/UnifySubScrutinees.mls +++ b/hkmc2/shared/src/test/mlscript/ucs/normalization/UnifySubScrutinees.mls @@ -16,23 +16,23 @@ fun foo(xs) = Nil then 3 //│ Desugared: //│ > if -//│ > xs@38 is Cons($param0@39, $param1@40) and $param0@39 is "abc" and $param1@40 is Cons($param0@41, $param1@42) and $param0@41 is "xyz" and -//│ > let xs@44 = $param1@42#1 +//│ > xs@20 is Cons($param0@21, $param1@22) and $param0@21 is "abc" and $param1@22 is Cons($param0@23, $param1@24) and $param0@23 is "xyz" and +//│ > let xs@26 = $param1@24#1 //│ > else 0 -//│ > xs@38 is Cons($param0@39, $param1@40) and $param0@39 is "abc" and $param1@40 is Cons($param0@41, $param1@42) and $param0@41 is "uvw" and -//│ > let xs@43 = $param1@42#0 +//│ > xs@20 is Cons($param0@21, $param1@22) and $param0@21 is "abc" and $param1@22 is Cons($param0@23, $param1@24) and $param0@23 is "uvw" and +//│ > let xs@25 = $param1@24#0 //│ > else 1 -//│ > xs@38 is Nil then 3 +//│ > xs@20 is Nil then 3 //│ Normalized: //│ > if -//│ > xs@38 is Cons($param0@39, $param1@40) and $param0@39 is "abc" and $param1@40 is Cons($param0@41, $param1@42) and -//│ > $param0@41 is "xyz" and -//│ > let xs@44 = $param1@42#1 +//│ > xs@20 is Cons($param0@21, $param1@22) and $param0@21 is "abc" and $param1@22 is Cons($param0@23, $param1@24) and +//│ > $param0@23 is "xyz" and +//│ > let xs@26 = $param1@24#1 //│ > else 0 -//│ > $param0@41 is "uvw" and -//│ > let xs@43 = $param1@42#0 +//│ > $param0@23 is "uvw" and +//│ > let xs@25 = $param1@24#0 //│ > else 1 -//│ > xs@38 is Nil then 3 +//│ > xs@20 is Nil then 3 fun sum(acc, xs) = if xs is @@ -40,18 +40,18 @@ fun sum(acc, xs) = Nil then acc //│ Desugared: //│ > if -//│ > xs@48 is Cons($param0@49, $param1@50) and -//│ > let x@51 = $param0@49#0 -//│ > let xs@52 = $param1@50#0 -//│ > else globalThis:block#3#666.sum‹member:sum›(globalThis:import#Prelude#666.+‹member:+›(acc@47#666, x@51#666), xs@52#666) -//│ > xs@48 is Nil then acc@47#666 +//│ > 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) +//│ > xs@30 is Nil then acc@29#666 //│ Normalized: //│ > if -//│ > xs@48 is Cons($param0@49, $param1@50) and -//│ > let x@51 = $param0@49#0 -//│ > let xs@52 = $param1@50#0 -//│ > else globalThis:block#3#666.sum‹member:sum›(globalThis:import#Prelude#666.+‹member:+›(acc@47#666, x@51#666), xs@52#666) -//│ > xs@48 is Nil then acc@47#666 +//│ > 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) +//│ > xs@30 is Nil then acc@29#666 :todo // The normalization does not distinguish between bindings and their aliases. @@ -66,37 +66,37 @@ fun test(xs) = None then "nothing" //│ Desugared: //│ > if -//│ > xs@57 is Some($param0@58) and $param0@58 is Cons($param0@59, $param1@60) and $param0@59 is "add" and $param1@60 is Cons($param0@63, $param1@64) and -//│ > let x@70 = $param0@63#1 -//│ > $param1@64 is Cons($param0@66, $param1@67) and -//│ > let y@71 = $param0@66#1 -//│ > $param1@67 is Nil then globalThis:import#Prelude#666.+‹member:+›(x@70#666, y@71#666) -//│ > xs@57 is Some($param0@58) and $param0@58 is Cons($param0@59, $param1@60) and $param0@59 is "mul" and $param1@60 is Cons($param0@63, $param1@64) and -//│ > let x@65 = $param0@63#0 -//│ > $param1@64 is Cons($param0@66, $param1@67) and -//│ > let y@68 = $param0@66#0 -//│ > $param1@67 is Nil then globalThis:import#Prelude#666.*‹member:*›(x@65#666, y@68#666) -//│ > xs@57 is Some($param0@58) and $param0@58 is Cons($param0@59, $param1@60) and $param0@59 is "sum" and -//│ > let xs@61 = $param1@60#0 -//│ > else globalThis:block#3#666.sum‹member:sum›(0, xs@61#666) -//│ > xs@57 is Some($param0@58) $param0@58 is Nil then "nothing" -//│ > xs@57 is None then "nothing" +//│ > xs@39 is Some($param0@40) and $param0@40 is Cons($param0@41, $param1@42) and $param0@41 is "add" and $param1@42 is Cons($param0@45, $param1@46) and +//│ > 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) +//│ > 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) +//│ > 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) +//│ > xs@39 is Some($param0@40) $param0@40 is Nil then "nothing" +//│ > xs@39 is None then "nothing" //│ Normalized: //│ > if -//│ > xs@57 is Some($param0@58) and -//│ > $param0@58 is Cons($param0@59, $param1@60) and -//│ > $param0@59 is "add" and $param1@60 is Cons($param0@63, $param1@64) and -//│ > let x@70 = $param0@63#1 -//│ > $param1@64 is Cons($param0@66, $param1@67) and -//│ > let y@71 = $param0@66#1 -//│ > $param1@67 is Nil then globalThis:import#Prelude#666.+‹member:+›(x@70#666, y@71#666) -//│ > $param0@59 is "mul" and $param1@60 is Cons($param0@63, $param1@64) and -//│ > let x@65 = $param0@63#0 -//│ > $param1@64 is Cons($param0@66, $param1@67) and -//│ > let y@68 = $param0@66#0 -//│ > $param1@67 is Nil then globalThis:import#Prelude#666.*‹member:*›(x@65#666, y@68#666) -//│ > $param0@59 is "sum" and -//│ > let xs@61 = $param1@60#0 -//│ > else globalThis:block#3#666.sum‹member:sum›(0, xs@61#666) -//│ > $param0@58 is Nil then "nothing" -//│ > xs@57 is None then "nothing" +//│ > xs@39 is Some($param0@40) and +//│ > $param0@40 is Cons($param0@41, $param1@42) and +//│ > $param0@41 is "add" and $param1@42 is Cons($param0@45, $param1@46) and +//│ > 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) +//│ > $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) +//│ > $param0@41 is "sum" and +//│ > let xs@43 = $param1@42#0 +//│ > else globalThis:block#3#666.sum‹member:sum›(0, xs@43#666) +//│ > $param0@40 is Nil then "nothing" +//│ > xs@39 is None then "nothing" diff --git a/hkmc2/shared/src/test/mlscript/ucs/papers/OperatorSplit.mls b/hkmc2/shared/src/test/mlscript/ucs/papers/OperatorSplit.mls index e1d7703a6..ba5cb8a47 100644 --- a/hkmc2/shared/src/test/mlscript/ucs/papers/OperatorSplit.mls +++ b/hkmc2/shared/src/test/mlscript/ucs/papers/OperatorSplit.mls @@ -78,13 +78,13 @@ fun example(args) = //│ params = Ls of //│ Param: //│ flags = () -//│ sym = args@40 +//│ sym = args@22 //│ sign = N //│ sign = N //│ body = S of IfLike: //│ kw = keyword 'if' //│ desugared = Let: -//│ sym = $scrut@42 +//│ sym = $scrut@24 //│ term = App: //│ lhs = Sel: //│ prefix = Ref of globalThis:block#1 @@ -92,18 +92,16 @@ fun example(args) = //│ rhs = Tup of Ls of //│ Fld: //│ flags = () -//│ value = Ref of args@40 +//│ value = Ref of args@22 //│ asc = N //│ tail = Let: \ -//│ sym = $scrut@52 +//│ sym = $scrut@34 //│ term = App: -//│ lhs = Sel: -//│ prefix = Ref of globalThis:import#Prelude -//│ nme = Ident of "<" +//│ lhs = Ref of builtin:< //│ rhs = Tup of Ls of //│ Fld: //│ flags = () -//│ value = Ref of $scrut@42 +//│ value = Ref of $scrut@24 //│ asc = N //│ Fld: //│ flags = () @@ -111,19 +109,17 @@ fun example(args) = //│ asc = N //│ tail = Cons: \ //│ head = Branch: -//│ scrutinee = Ref of $scrut@52 +//│ scrutinee = Ref of $scrut@34 //│ pattern = LitPat of BoolLit of true //│ continuation = Else of Lit of StrLit of "invalid" //│ tail = Let: \ -//│ sym = $scrut@50 +//│ sym = $scrut@32 //│ term = App: -//│ lhs = Sel: -//│ prefix = Ref of globalThis:import#Prelude -//│ nme = Ident of "==" +//│ lhs = Ref of builtin:== //│ rhs = Tup of Ls of //│ Fld: //│ flags = () -//│ value = Ref of $scrut@42 +//│ value = Ref of $scrut@24 //│ asc = N //│ Fld: //│ flags = () @@ -131,11 +127,11 @@ fun example(args) = //│ asc = N //│ tail = Cons: \ //│ head = Branch: -//│ scrutinee = Ref of $scrut@50 +//│ scrutinee = Ref of $scrut@32 //│ pattern = LitPat of BoolLit of true //│ continuation = Else of Lit of StrLit of "null" //│ tail = Let: \ -//│ sym = $scrut@44 +//│ sym = $scrut@26 //│ term = App: //│ lhs = Sel: //│ prefix = Ref of globalThis:block#1 @@ -143,7 +139,7 @@ fun example(args) = //│ rhs = Tup of Ls of //│ Fld: //│ flags = () -//│ value = Ref of $scrut@42 +//│ value = Ref of $scrut@24 //│ asc = N //│ Fld: //│ flags = () @@ -152,15 +148,13 @@ fun example(args) = //│ nme = Ident of "abs" //│ asc = N //│ tail = Let: \ -//│ sym = $scrut@48 +//│ sym = $scrut@30 //│ term = App: -//│ lhs = Sel: -//│ prefix = Ref of globalThis:import#Prelude -//│ nme = Ident of ">" +//│ lhs = Ref of builtin:> //│ rhs = Tup of Ls of //│ Fld: //│ flags = () -//│ value = Ref of $scrut@44 +//│ value = Ref of $scrut@26 //│ asc = N //│ Fld: //│ flags = () @@ -168,19 +162,17 @@ fun example(args) = //│ asc = N //│ tail = Cons: \ //│ head = Branch: -//│ scrutinee = Ref of $scrut@48 +//│ scrutinee = Ref of $scrut@30 //│ pattern = LitPat of BoolLit of true //│ continuation = Else of Lit of StrLit of "large" //│ tail = Let: \ -//│ sym = $scrut@46 +//│ sym = $scrut@28 //│ term = App: -//│ lhs = Sel: -//│ prefix = Ref of globalThis:import#Prelude -//│ nme = Ident of "<" +//│ lhs = Ref of builtin:< //│ rhs = Tup of Ls of //│ Fld: //│ flags = () -//│ value = Ref of $scrut@44 +//│ value = Ref of $scrut@26 //│ asc = N //│ Fld: //│ flags = () @@ -188,11 +180,11 @@ fun example(args) = //│ asc = N //│ tail = Cons: \ //│ head = Branch: -//│ scrutinee = Ref of $scrut@46 +//│ scrutinee = Ref of $scrut@28 //│ pattern = LitPat of BoolLit of true //│ continuation = Else of Lit of StrLit of "small" //│ tail = Else of Lit of StrLit of "medium" -//│ resSym = ‹result of member:example›@53 +//│ resSym = ‹result of member:example›@35 //│ res = Lit of UnitLit of true diff --git a/hkmc2/shared/src/test/mlscript/ucs/patterns/AliasPattern.mls b/hkmc2/shared/src/test/mlscript/ucs/patterns/AliasPattern.mls index ea080895b..5304c8916 100644 --- a/hkmc2/shared/src/test/mlscript/ucs/patterns/AliasPattern.mls +++ b/hkmc2/shared/src/test/mlscript/ucs/patterns/AliasPattern.mls @@ -9,32 +9,32 @@ fun map(f) = case None as n then n //│ Desugared: //│ > if -//│ > caseScrut@33 is Some($param0@35) and -//│ > let x@36 = $param0@35#0 -//│ > else globalThis:import#Option#666.Some‹member:Some›(f@32#666(x@36#666)) -//│ > caseScrut@33 is None and -//│ > let n@34 = caseScrut@33#1 -//│ > else n@34#666 +//│ > caseScrut@15 is Some($param0@17) and +//│ > let x@18 = $param0@17#0 +//│ > else globalThis:import#Option#666.Some‹member:Some›(f@14#666(x@18#666)) +//│ > caseScrut@15 is None and +//│ > let n@16 = caseScrut@15#1 +//│ > else n@16#666 fun map(f) = case Some(x as n) then Some of f(n) None as n then n //│ Desugared: //│ > if -//│ > caseScrut@42 is Some($param0@44) and -//│ > let x@46 = $param0@44#0 -//│ > let n@45 = $param0@44#1 -//│ > else globalThis:import#Option#666.Some‹member:Some›(f@41#666(n@45#666)) -//│ > caseScrut@42 is None and -//│ > let n@43 = caseScrut@42#1 -//│ > else n@43#666 +//│ > caseScrut@24 is Some($param0@26) and +//│ > let x@28 = $param0@26#0 +//│ > let n@27 = $param0@26#1 +//│ > else globalThis:import#Option#666.Some‹member:Some›(f@23#666(n@27#666)) +//│ > caseScrut@24 is None and +//│ > let n@25 = caseScrut@24#1 +//│ > else n@25#666 fun foo = case Some(Some(a as b) as c) as d then [a, b, c, d] //│ Desugared: -//│ > if caseScrut@51 is Some($param0@53) and $param0@53 is Some($param0@55) and -//│ > let a@57 = $param0@55#0 -//│ > let b@56 = $param0@55#1 -//│ > let c@54 = $param0@53#1 -//│ > let d@52 = caseScrut@51#1 -//│ > else [a@57#666, b@56#666, c@54#666, d@52#666] +//│ > if caseScrut@33 is Some($param0@35) and $param0@35 is Some($param0@37) and +//│ > let a@39 = $param0@37#0 +//│ > let b@38 = $param0@37#1 +//│ > let c@36 = $param0@35#1 +//│ > let d@34 = caseScrut@33#1 +//│ > else [a@39#666, b@38#666, c@36#666, d@34#666] diff --git a/hkmc2/shared/src/test/mlscript/ucs/patterns/NamePattern.mls b/hkmc2/shared/src/test/mlscript/ucs/patterns/NamePattern.mls index 7e5dd72dd..eb4d80c4e 100644 --- a/hkmc2/shared/src/test/mlscript/ucs/patterns/NamePattern.mls +++ b/hkmc2/shared/src/test/mlscript/ucs/patterns/NamePattern.mls @@ -4,6 +4,6 @@ fun id(x) = x if id(0) is t then t //│ Desugared: //│ > if -//│ > let $scrut@33 = member:Predef#666.id‹member:id›(0) -//│ > let t@34 = $scrut@33#0 -//│ > else t@34#666 +//│ > let $scrut@15 = member:Predef#666.id‹member:id›(0) +//│ > let t@16 = $scrut@15#0 +//│ > else t@16#666 diff --git a/hkmc2/shared/src/test/mlscript/ucs/patterns/Refinement.mls b/hkmc2/shared/src/test/mlscript/ucs/patterns/Refinement.mls index 70368c898..e8bbfb070 100644 --- a/hkmc2/shared/src/test/mlscript/ucs/patterns/Refinement.mls +++ b/hkmc2/shared/src/test/mlscript/ucs/patterns/Refinement.mls @@ -40,7 +40,7 @@ x => if x is //│ ║ l.34: refined(None) then x //│ ╙── ^^^^^^^ //│ Normalized: -//│ > if x@36 is Some then x@36#666 +//│ > if x@18 is Some then x@18#666 x => if x is refined(None) then x diff --git a/hkmc2/shared/src/test/mlscript/ucs/syntax/NestedOpSplits.mls b/hkmc2/shared/src/test/mlscript/ucs/syntax/NestedOpSplits.mls index 65a71dead..953fcb507 100644 --- a/hkmc2/shared/src/test/mlscript/ucs/syntax/NestedOpSplits.mls +++ b/hkmc2/shared/src/test/mlscript/ucs/syntax/NestedOpSplits.mls @@ -20,36 +20,32 @@ fun f(x) = //│ params = Ls of //│ Param: //│ flags = () -//│ sym = x@29 +//│ sym = x@11 //│ sign = N //│ sign = N //│ body = S of IfLike: //│ kw = keyword 'if' //│ desugared = Let: -//│ sym = $scrut@31 +//│ sym = $scrut@13 //│ term = App: -//│ lhs = Sel: -//│ prefix = Ref of globalThis:import#Prelude -//│ nme = Ident of "==" +//│ lhs = Ref of builtin:== //│ rhs = Tup of Ls of //│ Fld: //│ flags = () -//│ value = Ref of x@29 +//│ value = Ref of x@11 //│ asc = N //│ Fld: //│ flags = () //│ value = Lit of IntLit of 1 //│ asc = N //│ tail = Let: \ -//│ sym = $scrut@33 +//│ sym = $scrut@15 //│ term = App: -//│ lhs = Sel: -//│ prefix = Ref of globalThis:import#Prelude -//│ nme = Ident of "+" +//│ lhs = Ref of builtin:+ //│ rhs = Tup of Ls of //│ Fld: //│ flags = () -//│ value = Ref of $scrut@31 +//│ value = Ref of $scrut@13 //│ asc = N //│ Fld: //│ flags = () @@ -57,11 +53,11 @@ fun f(x) = //│ asc = N //│ tail = Cons: \ //│ head = Branch: -//│ scrutinee = Ref of $scrut@33 +//│ scrutinee = Ref of $scrut@15 //│ pattern = LitPat of BoolLit of true //│ continuation = Else of Lit of IntLit of 0 //│ tail = Else of Lit of IntLit of 1 -//│ resSym = ‹result of member:f›@34 +//│ resSym = ‹result of member:f›@16 //│ res = Lit of UnitLit of true