From 3a31c6ea2221a74d813982e630f8e2ae4cdc167a Mon Sep 17 00:00:00 2001 From: Lionel Parreaux Date: Sat, 11 Jan 2025 15:20:06 +0800 Subject: [PATCH] Improve handling of symbolic names --- .../src/main/scala/hkmc2/bbml/bbML.scala | 2 + .../scala/hkmc2/semantics/BlockImpl.scala | 6 +- .../scala/hkmc2/semantics/Desugarer.scala | 12 +-- .../scala/hkmc2/semantics/Elaborator.scala | 16 +++- .../hkmc2/semantics/ucs/Translator.scala | 8 +- .../src/main/scala/hkmc2/syntax/Parser.scala | 10 +-- .../src/main/scala/hkmc2/syntax/Tree.scala | 88 +++++++++++-------- .../src/test/mlscript/backlog/ToTriage.mls | 12 +-- .../src/test/mlscript/basics/BadClasses.mls | 8 +- .../src/test/mlscript/basics/BadDefs.mls | 67 ++++++++++++++ .../src/test/mlscript/basics/BlockArgs.mls | 4 +- .../src/test/mlscript/basics/Classes.mls | 4 +- .../test/mlscript/basics/ModuleMethods.mls | 4 +- .../src/test/mlscript/basics/OpBlocks.mls | 8 +- .../test/mlscript/basics/RefinedClasses.mls | 18 ++-- .../src/test/mlscript/basics/StrTest.mls | 2 +- .../src/test/mlscript/basics/WeirdCalls.mls | 22 +++-- hkmc2/shared/src/test/mlscript/bbml/bbRec.mls | 11 ++- .../test/mlscript/codegen/BadFunctions.mls | 3 + .../src/test/mlscript/codegen/BadOpen.mls | 16 +++- .../src/test/mlscript/codegen/Bindings.mls | 9 +- .../src/test/mlscript/codegen/FunnyOpen.mls | 14 +-- .../test/mlscript/codegen/Juxtapositions.mls | 4 +- .../shared/src/test/mlscript/parser/Block.mls | 4 +- .../src/test/mlscript/parser/BoolOps.mls | 4 +- hkmc2/shared/src/test/mlscript/parser/Of.mls | 10 +-- .../shared/src/test/mlscript/parser/Semis.mls | 4 +- hkmc2/shared/src/test/mlscript/rp/Future.mls | 6 +- .../src/test/mlscript/rp/RangePatterns.mls | 2 +- .../mlscript/syntax/annotations/Pattern.mls | 2 +- .../syntax/annotations/Unsupported.mls | 2 +- .../test/mlscript/ucs/future/AppSplits.mls | 12 +-- .../src/test/mlscript/ucs/future/Or.mls | 2 +- .../mlscript/ucs/syntax/ConjunctMatches.mls | 22 ++--- .../test/mlscript/ucs/syntax/SimpleUCS.mls | 2 +- 35 files changed, 270 insertions(+), 150 deletions(-) create mode 100644 hkmc2/shared/src/test/mlscript/basics/BadDefs.mls diff --git a/hkmc2/shared/src/main/scala/hkmc2/bbml/bbML.scala b/hkmc2/shared/src/main/scala/hkmc2/bbml/bbML.scala index c1b71266e..9f43bca05 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/bbml/bbML.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/bbml/bbML.scala @@ -435,6 +435,8 @@ class BBTyper(using elState: Elaborator.State, tl: TL, scope: Scope): goStats(stats) case Import(sym, pth) :: stats => goStats(stats) // TODO: + case stat :: _ => + TODO(stat) goStats(stats) val (ty, eff) = typeCheck(res) (ty, effBuff.foldLeft(eff)((res, e) => res | e)) diff --git a/hkmc2/shared/src/main/scala/hkmc2/semantics/BlockImpl.scala b/hkmc2/shared/src/main/scala/hkmc2/semantics/BlockImpl.scala index 6a11d435c..144dd6bf3 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/semantics/BlockImpl.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/semantics/BlockImpl.scala @@ -3,7 +3,7 @@ package semantics import mlscript.utils.*, shorthands.* import syntax.Tree.* -import hkmc2.syntax.{Annotations, TypeOrTermDef} +import hkmc2.syntax.{PossiblyAnnotated, TypeOrTermDef} trait BlockImpl(using Elaborator.State): @@ -14,13 +14,13 @@ trait BlockImpl(using Elaborator.State): val definedSymbols: Array[Str -> BlockMemberSymbol] = desugStmts .flatMap: - case Annotations(_, td: syntax.TypeOrTermDef) => + case PossiblyAnnotated(_, td: syntax.TypeOrTermDef) => td.name match case L(_) => Nil case R(id) => id.name -> R(td) :: ( td.symbName match - case S(sid: Ident) => id.name -> L(sid.name) :: Nil + case S(R(sid)) => id.name -> L(sid.name) :: Nil case _ => Nil ) case _ => Nil diff --git a/hkmc2/shared/src/main/scala/hkmc2/semantics/Desugarer.scala b/hkmc2/shared/src/main/scala/hkmc2/semantics/Desugarer.scala index 25e0dfa22..7d0400882 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/semantics/Desugarer.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/semantics/Desugarer.scala @@ -349,7 +349,7 @@ class Desugarer(val elaborator: Elaborator) case blk: Block => blk.desugStmts.foldRight(default): (branch, elabFallback) => // Terminology: _fallback_ refers to subsequent branches, _backup_ refers // to the backup plan passed from the parent split. - branch match + branch.deparenthesized match case LetLike(`let`, ident @ Ident(_), termTree, N) => backup => ctx => termTree match case S(termTree) => @@ -409,7 +409,7 @@ class Desugarer(val elaborator: Elaborator) */ def expandMatch(scrutSymbol: BlockLocalSymbol, pattern: Tree, sequel: Sequel): Split => Sequel = def ref = scrutSymbol.ref(/* FIXME ident? */) - pattern match + pattern.deparenthesized match // A single wildcard pattern. case Under() => _ => ctx => sequel(ctx) // Alias pattern @@ -510,17 +510,17 @@ class Desugarer(val elaborator: Elaborator) ): Branch(ref, Pattern.Lit(literal), sequel(ctx)) ~: fallback // A single pattern in conjunction with more conditions - case pattern and consequent => fallback => ctx => + case pattern and consequent => fallback => ctx => val innerSplit = termSplit(consequent, identity)(Split.End) expandMatch(scrutSymbol, pattern, innerSplit)(fallback)(ctx) case Jux(Ident(".."), Ident(_)) => fallback => _ => - raise(ErrorReport(msg"Illgeal rest pattern." -> pattern.toLoc :: Nil)) + raise(ErrorReport(msg"Illegal rest pattern." -> pattern.toLoc :: Nil)) fallback case _ => fallback => _ => // Raise an error and discard `sequel`. Use `fallback` instead. - raise(ErrorReport(msg"Unrecognized pattern." -> pattern.toLoc :: Nil)) + raise(ErrorReport(msg"Unrecognized pattern (${pattern.describe})" -> pattern.toLoc :: Nil)) fallback - + /** Desugar a list of sub-patterns (with their corresponding scrutinees). * This is called when handling nested patterns. The caller is responsible * for providing the symbols of scrutinees. diff --git a/hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala b/hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala index c4735e825..8005d01b5 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/semantics/Elaborator.scala @@ -183,6 +183,12 @@ extends Importer: def term(tree: Tree, inAppPrefix: Bool = false): Ctxl[Term] = trace[Term](s"Elab term ${tree.showDbg}", r => s"~> $r"): tree.desugared match + case Bra(k, e) => + k match + case BracketKind.Round => + case _ => + raise(ErrorReport(msg"Unsupported ${k.name} in this position" -> tree.toLoc :: Nil)) + term(e) case Block(s :: Nil) => term(s) case Block(sts) => @@ -713,6 +719,9 @@ extends Importer: go(sts, Nil, Term.Error :: acc) case (td @ TermDef(k, nme, rhs)) :: sts => log(s"Processing term definition $nme") + td.symbName match + case S(L(d)) => raise(d) + case _ => () td.name match case R(id) => val sym = members.getOrElse(id.name, die) @@ -759,11 +768,11 @@ extends Importer: s match case N if em => raise: ErrorReport: - msg"Function returning module values must have explicit return types." -> + msg"Functions returning module values must have explicit return types." -> td.head.toLoc :: Nil case S(t) if em && ModuleChecker.isTypeParam(t) => raise: ErrorReport: - msg"Function returning module values must have concrete return types." -> + msg"Functions returning module values must have concrete return types." -> td.head.toLoc :: Nil case S(_) if em && !mm => raise: ErrorReport: @@ -783,6 +792,9 @@ extends Importer: go(sts, Nil, acc) case (td @ TypeDef(k, head, extension, body)) :: sts => assert((k is Als) || (k is Cls) || (k is Mod) || (k is Obj) || (k is Pat), k) + td.symbName match + case S(L(d)) => raise(d) + case _ => () val nme = td.name match case R(id) => id case L(d) => diff --git a/hkmc2/shared/src/main/scala/hkmc2/semantics/ucs/Translator.scala b/hkmc2/shared/src/main/scala/hkmc2/semantics/ucs/Translator.scala index 3d729bd87..471b8d6d0 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/semantics/ucs/Translator.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/semantics/ucs/Translator.scala @@ -89,7 +89,7 @@ class Translator(val elaborator: Elaborator) pre = s"full <<< $pat", post = (split: Split) => s"full >>> $split" ): - pat match + pat.deparenthesized match case lhs or rhs => full(scrut, lhs, inner) ~~: full(scrut, rhs, inner) case (lo: StrLit) to (incl, hi: StrLit) => if isInvalidStringBounds(lo, hi) then failure else makeRange(scrut, lo, hi, incl, inner) @@ -113,7 +113,7 @@ class Translator(val elaborator: Elaborator) error(msg"Cannot use this ${ctor.describe} as an extractor" -> ctor.toLoc) errorSplit case _ => - error(msg"Unrecognized pattern." -> pat.toLoc) + error(msg"Unrecognized pattern (${pat.describe})" -> pat.toLoc) errorSplit /** Generate a split that consumes the prefix of the scrutinee. */ @@ -121,7 +121,7 @@ class Translator(val elaborator: Elaborator) pre = s"stringPrefix <<< $pat", post = (split: Split) => s"stringPrefix >>> $split" ): - pat match + pat.deparenthesized match case lhs or rhs => stringPrefix(scrut, lhs, inner) ~~: stringPrefix(scrut, rhs, inner) case (lo: StrLit) to (incl, hi: StrLit) => if isInvalidStringBounds(lo, hi) then failure else val emptyTest = app(eq.ref(), tup(fld(scrut()), fld(str(""))), "test empty") @@ -160,7 +160,7 @@ class Translator(val elaborator: Elaborator) error(msg"Cannot use this ${ctor.describe} as an extractor" -> ctor.toLoc) errorSplit case _ => - error(msg"Unrecognized pattern." -> pat.toLoc) + error(msg"Unrecognized pattern (${pat.describe})" -> pat.toLoc) errorSplit /** Create a function that compiles the resulting term of each case. It checks diff --git a/hkmc2/shared/src/main/scala/hkmc2/syntax/Parser.scala b/hkmc2/shared/src/main/scala/hkmc2/syntax/Parser.scala index 302660de0..57700b1c3 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/syntax/Parser.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/syntax/Parser.scala @@ -527,8 +527,8 @@ abstract class Parser( case Square => Tup(sts).withLoc(S(loc)) case Round => sts match case Nil => UnitLit(true).withLoc(S(loc)) - case e :: Nil => e - case es => Block(es).withLoc(S(loc)) + case e :: Nil => Bra(Round, e).withLoc(S(loc)) + case es => Bra(Round, Block(es).withLoc(S(loc))) exprCont(res, prec, allowNewlines = true) case (QUOTE, loc) :: _ => consume @@ -767,7 +767,7 @@ abstract class Parser( consume // rec(toks, S(br.innerLoc), br.describe).concludeWith(f(_, true)) val rhs = rec(toks, S(l0), "operator split").concludeWith(_.split) - App(v, PlainTup(acc, Block(rhs))) + App(v, PlainTup(acc, Block(rhs).withLoc(S(l0)))) case _ => // val rhs = simpleExpr(opPrec(opStr)._2) val rhs = expr(opPrec(opStr)._2) @@ -988,7 +988,7 @@ abstract class Parser( if prec < AppPrec && !Keyword.all.contains(id) => val res = exprCont(Jux(acc, expr(AppPrec)), prec, allowNewlines) exprJux(res, prec, allowNewlines) - case (br @ BRACKETS(Curly | Indent, toks), _) :: _ + case (br @ BRACKETS(Curly | Indent, toks), l0) :: _ if prec < AppPrec && (toks.headOption match case S((IDENT(nme, sym), _)) => !sym && !Keyword.all.contains(nme) case _ => true @@ -996,7 +996,7 @@ abstract class Parser( consume val res = rec(toks, S(br.innerLoc), br.describe).concludeWith: _.block(allowNewlines = true) - exprCont(Jux(acc, Block(res)), prec, allowNewlines = true) + exprCont(Jux(acc, Block(res).withLoc(S(l0))), prec, allowNewlines = true) case (tok, _) :: _ => printDbg(s"stops at ${tok.toString}") diff --git a/hkmc2/shared/src/main/scala/hkmc2/syntax/Tree.scala b/hkmc2/shared/src/main/scala/hkmc2/syntax/Tree.scala index b970324f0..821312b8b 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/syntax/Tree.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/syntax/Tree.scala @@ -48,6 +48,7 @@ enum Tree extends AutoLocated: case StrLit(value: Str) extends Tree with Literal case UnitLit(undefinedOrNull: Bool) extends Tree with Literal case BoolLit(value: Bool) extends Tree with Literal + case Bra(k: BracketKind, inner: Tree) case Block(stmts: Ls[Tree])(using State) extends Tree with semantics.BlockImpl case OpBlock(items: Ls[Tree -> Tree]) case LetLike(kw: Keyword.letLike, lhs: Tree, rhs: Opt[Tree], body: Opt[Tree]) @@ -81,6 +82,7 @@ enum Tree extends AutoLocated: def children: Ls[Tree] = this match case _: Empty | _: Error | _: Ident | _: Literal | _: Under => Nil + case Bra(_, e) => e :: Nil case Block(stmts) => stmts case OpBlock(items) => items.flatMap: case (op, body) => op :: body :: Nil @@ -115,7 +117,7 @@ enum Tree extends AutoLocated: def describe: Str = this match case Empty() => "empty" - case Error() => "error" + case Error() => "" case Under() => "underscore" case Ident(name) => "identifier" case IntLit(value) => "integer literal" @@ -123,6 +125,7 @@ enum Tree extends AutoLocated: case StrLit(value) => "string literal" case UnitLit(value) => if value then "null" else "undefined" case BoolLit(value) => s"$value literal" + case Bra(k, _) => k.name + " section" case Block(stmts) => "block" case OpBlock(_) => "operator block" case LetLike(kw, lhs, rhs, body) => kw.name @@ -150,6 +153,10 @@ enum Tree extends AutoLocated: case Spread(_, _, _) => "spread" case Annotated(_, _) => "annotated" case Open(_) => "open" + + def deparenthesized: Tree = this match + case Bra(BracketKind.Round, inner) => inner.deparenthesized + case _ => this def showDbg: Str = toString // TODO @@ -208,11 +215,16 @@ object Apps: case App(Apps(base, args), arg: Tup) => S(base, args :+ arg) case t => S(t, Nil) -object Annotations: +object PossiblyAnnotated: def unapply(t: Tree): Opt[(Ls[Tree], Tree)] = t match - case Annotated(q, Annotations(qs, target)) => S(q :: qs, target) + case Annotated(q, PossiblyAnnotated(qs, target)) => S(q :: qs, target) case other => S((Nil, other)) +object PossiblyParenthesized: + def unapply(t: Tree): S[Tree] = t match + case Bra(BracketKind.Round, inner) => S(inner) + case _ => S(t) + /** Matches applications with underscores in some argument and/or prefix positions. */ object PartialApp: def unapply(t: App): Opt[(Tree \/ Under, Ls[Tree \/ Under])] = t match @@ -259,60 +271,64 @@ trait TermDefImpl extends TypeOrTermDef: trait TypeOrTermDef: this: TypeDef | TermDef => + def k: DeclKind def head: Tree + type MaybeIdent = Diagnostic \/ Ident + lazy val (symbName, name, paramLists, typeParams, annotatedResultType) - : (Opt[Tree], Diagnostic \/ Ident, Ls[Tup], Opt[TyTup], Opt[Tree]) = - def rec(t: Tree, symbName: Opt[Tree]): - (Opt[Tree], Diagnostic \/ Ident, Ls[Tup], Opt[TyTup], Opt[Tree]) = + : (Opt[MaybeIdent], MaybeIdent, Ls[Tup], Opt[TyTup], Opt[Tree]) = + def rec(t: Tree, symbName: Opt[MaybeIdent], annot: Opt[Tree]): + (Opt[MaybeIdent], MaybeIdent, Ls[Tup], Opt[TyTup], Opt[Tree]) = t match - // fun f: Int - // fun f(n1: Int): Int - // fun f(n1: Int)(nn: Int): Int - case InfixApp(Apps(id: Ident, paramLists), Keyword.`:`, sign) => - (symbName, R(id), paramLists, N, S(sign)) - - // fun f[T]: Int - // fun f[T](n1: Int): Int - // fun f[T](n1: Int)(nn: Int): Int - case InfixApp(Apps(App(id: Ident, typeParams: TyTup), paramLists), Keyword.`:`, ret) => - (symbName, R(id), paramLists, S(typeParams), S(ret)) - - case InfixApp(Jux(lhs, rhs), Keyword.`:`, ret) => - rec(InfixApp(rhs, Keyword.`:`, ret), S(lhs)) + case InfixApp(tree, Keyword.`:`, ann) => + rec(tree, symbName, S(ann)) case InfixApp(derived, Keyword.`extends`, base) => // TODO handle `extends`! - rec(derived, symbName) + rec(derived, symbName, annot) // fun f // fun f(n1: Int) // fun f(n1: Int)(nn: Int) - case Apps(id: Ident, paramLists) => - (symbName, R(id), paramLists, N, N) + case Apps(PossiblyParenthesized(id: Ident), paramLists) => + (symbName, R(id), paramLists, N, annot) // fun f[T] // fun f[T](n1: Int) // fun f[T](n1: Int)(nn: Int) - case Apps(App(id: Ident, typeParams: TyTup), paramLists) => - (symbName, R(id), paramLists, S(typeParams), N) - - case Jux(lhs, rhs) => // happens in `fun (op) nme` form - require(symbName.isEmpty) // TOOD - rec(rhs, S(lhs)) + case Apps(App(PossiblyParenthesized(id: Ident), typeParams: TyTup), paramLists) => + (symbName, R(id), paramLists, S(typeParams), annot) + + case Jux(id: Ident, rhs) => + val err = L: + ErrorReport: + msg"Invalid ${k.desc} definition head: unexpected ${rhs.describe} in this position" -> rhs.toLoc :: Nil + (S(err), R(id), Nil, N, annot) + case Jux(lhs, rhs) => // happens in `fun (op) nme` form + val sn = lhs match + case Bra(BracketKind.Round, id: Ident) => + require(symbName.isEmpty) // TODO + R(id) + case Bra(BracketKind.Round, lhs) => + L: + ErrorReport: + msg"This ${lhs.describe} is not a valid symbolic name" -> lhs.toLoc :: Nil + case tree => + L: + ErrorReport: + msg"Invalid ${k.desc} definition head: unexpected ${lhs.describe} in this position" -> lhs.toLoc :: Nil + rec(rhs, S(sn), annot) + case _ => (N, L(ErrorReport( - msg"Expected a valid definition head, found ${t.describe} instead" -> t.toLoc :: Nil)), - Nil, N, N) + msg"Expected a valid ${k.desc} definition head; found ${t.describe} instead" -> t.toLoc :: Nil)), + Nil, N, annot) - rec(head, N) + rec(head, N, N) - lazy val symbolicName: Opt[Ident] = symbName match - case S(id: Ident) => S(id) - case _ => N - end TypeOrTermDef diff --git a/hkmc2/shared/src/test/mlscript/backlog/ToTriage.mls b/hkmc2/shared/src/test/mlscript/backlog/ToTriage.mls index 8c78b8f5b..56db026e9 100644 --- a/hkmc2/shared/src/test/mlscript/backlog/ToTriage.mls +++ b/hkmc2/shared/src/test/mlscript/backlog/ToTriage.mls @@ -50,24 +50,24 @@ fun (++) t() = 1 //│ ╔══[ERROR] Multiple definitions of symbol '**' //│ ╟── defined here //│ ║ l.48: fun (**) t() = 0 -//│ ║ ^^^^^^^^^^^ +//│ ║ ^^^^^^^^^^^^ //│ ╟── defined here //│ ║ l.49: fun (++) t() = 1 -//│ ╙── ^^^^^^^^^^^ +//│ ╙── ^^^^^^^^^^^^ //│ ╔══[ERROR] Multiple definitions of symbol '++' //│ ╟── defined here //│ ║ l.48: fun (**) t() = 0 -//│ ║ ^^^^^^^^^^^ +//│ ║ ^^^^^^^^^^^^ //│ ╟── defined here //│ ║ l.49: fun (++) t() = 1 -//│ ╙── ^^^^^^^^^^^ +//│ ╙── ^^^^^^^^^^^^ //│ ╔══[ERROR] Multiple definitions of symbol 't' //│ ╟── defined here //│ ║ l.48: fun (**) t() = 0 -//│ ║ ^^^^^^^^^^^ +//│ ║ ^^^^^^^^^^^^ //│ ╟── defined here //│ ║ l.49: fun (++) t() = 1 -//│ ╙── ^^^^^^^^^^^ +//│ ╙── ^^^^^^^^^^^^ // ——— ——— ——— diff --git a/hkmc2/shared/src/test/mlscript/basics/BadClasses.mls b/hkmc2/shared/src/test/mlscript/basics/BadClasses.mls index 6473ea8a3..1a18a9222 100644 --- a/hkmc2/shared/src/test/mlscript/basics/BadClasses.mls +++ b/hkmc2/shared/src/test/mlscript/basics/BadClasses.mls @@ -4,15 +4,15 @@ :e class Foo { log("hi") } -//│ ╔══[ERROR] Expected a valid definition head, found block instead +//│ ╔══[ERROR] Invalid class definition head: unexpected block in this position //│ ║ l.6: class Foo { log("hi") } -//│ ╙── ^^^^^^^^^ +//│ ╙── ^^^^^^^^^^^^^ :e class Foo { 1 } -//│ ╔══[ERROR] Expected a valid definition head, found block instead +//│ ╔══[ERROR] Invalid class definition head: unexpected block in this position //│ ║ l.12: class Foo { 1 } -//│ ╙── ^ +//│ ╙── ^^^^^ // Note that these work: diff --git a/hkmc2/shared/src/test/mlscript/basics/BadDefs.mls b/hkmc2/shared/src/test/mlscript/basics/BadDefs.mls new file mode 100644 index 000000000..fb8e257a0 --- /dev/null +++ b/hkmc2/shared/src/test/mlscript/basics/BadDefs.mls @@ -0,0 +1,67 @@ +:js + + +val (++) x = 0 +//│ ++ = 0 +//│ x = 0 + +x +//│ = 0 + +++ +//│ = 0 + + +:e +:ge +val ++ y = 1 +//│ ╔══[ERROR] Invalid value definition head: unexpected identifier in this position +//│ ║ l.17: val ++ y = 1 +//│ ╙── ^ +//│ > try { this.++ = 1; null } catch (e) { console.log('\u200B' + e + '\u200B'); } +//│ > ^^ +//│ ═══[COMPILATION ERROR] [Uncaught SyntaxError] Unexpected token '++' +//│ > try { ++ } catch (e) { console.log('\u200B' + e + '\u200B'); } +//│ > ^ +//│ ═══[COMPILATION ERROR] [Uncaught SyntaxError] Unexpected token '}' + +:e +y +//│ ╔══[ERROR] Name not found: y +//│ ║ l.29: y +//│ ╙── ^ + +++ + + +:e +:ge +fun ++ z = 0 +//│ ╔══[ERROR] Invalid function definition head: unexpected identifier in this position +//│ ║ l.39: fun ++ z = 0 +//│ ╙── ^ +//│ > try { function ++() { return 0; } null } catch (e) { console.log('\u200B' + e + '\u200B'); } +//│ > ^^ +//│ ═══[COMPILATION ERROR] [Uncaught SyntaxError] Unexpected token '++' + +:re +++ +//│ ═══[RUNTIME ERROR] TypeError: this.++ is not a function + + +:e +fun (class Lol) foo = 0 +//│ ╔══[ERROR] This type definition is not a valid symbolic name +//│ ║ l.53: fun (class Lol) foo = 0 +//│ ╙── ^^^ + +foo +//│ = 0 + +:e +Lol +//│ ╔══[ERROR] Name not found: Lol +//│ ║ l.62: Lol +//│ ╙── ^^^ + + diff --git a/hkmc2/shared/src/test/mlscript/basics/BlockArgs.mls b/hkmc2/shared/src/test/mlscript/basics/BlockArgs.mls index 160a2cf81..fb4fe6b1f 100644 --- a/hkmc2/shared/src/test/mlscript/basics/BlockArgs.mls +++ b/hkmc2/shared/src/test/mlscript/basics/BlockArgs.mls @@ -3,9 +3,9 @@ fun foo(x){f} = f(x) -//│ ╔══[ERROR] Expected a valid definition head, found block instead +//│ ╔══[ERROR] Expected a valid function definition head; found block instead //│ ║ l.4: fun foo(x){f} = -//│ ╙── ^ +//│ ╙── ^^^ foo(1){x => x} //│ ╔══[ERROR] Name not found: foo diff --git a/hkmc2/shared/src/test/mlscript/basics/Classes.mls b/hkmc2/shared/src/test/mlscript/basics/Classes.mls index 465fad3a6..c649619ae 100644 --- a/hkmc2/shared/src/test/mlscript/basics/Classes.mls +++ b/hkmc2/shared/src/test/mlscript/basics/Classes.mls @@ -30,9 +30,9 @@ class Foo(x: Int) :fixme :e class Foo(x: Int) { log("Hello!") } -//│ ╔══[ERROR] Expected a valid definition head, found block instead +//│ ╔══[ERROR] Expected a valid class definition head; found block instead //│ ║ l.32: class Foo(x: Int) { log("Hello!") } -//│ ╙── ^^^^^^^^^^^^^ +//│ ╙── ^^^^^^^^^^^^^^^^^ //│ JS (unsanitized): //│ this. = class { constructor() {} toString() { return ""; } }; null //│ > try { this. = class { constructor() {} toString() { return ""; } }; null } catch (e) { console.log('\u200B' + e + '\u200B'); } diff --git a/hkmc2/shared/src/test/mlscript/basics/ModuleMethods.mls b/hkmc2/shared/src/test/mlscript/basics/ModuleMethods.mls index 4a879df5e..982e6f88d 100644 --- a/hkmc2/shared/src/test/mlscript/basics/ModuleMethods.mls +++ b/hkmc2/shared/src/test/mlscript/basics/ModuleMethods.mls @@ -26,14 +26,14 @@ fun f2[T](module m: T) :e module N with fun f3() = M -//│ ╔══[ERROR] Function returning module values must have explicit return types. +//│ ╔══[ERROR] Functions returning module values must have explicit return types. //│ ║ l.28: fun f3() = M //│ ╙── ^^^^ :e module N with fun f4[T](): module T = M -//│ ╔══[ERROR] Function returning module values must have concrete return types. +//│ ╔══[ERROR] Functions returning module values must have concrete return types. //│ ║ l.35: fun f4[T](): module T = M //│ ╙── ^^^^^^^^^^^^^^^^^ diff --git a/hkmc2/shared/src/test/mlscript/basics/OpBlocks.mls b/hkmc2/shared/src/test/mlscript/basics/OpBlocks.mls index 9d3318d39..d14017336 100644 --- a/hkmc2/shared/src/test/mlscript/basics/OpBlocks.mls +++ b/hkmc2/shared/src/test/mlscript/basics/OpBlocks.mls @@ -180,9 +180,7 @@ fun f(x) = if x //│ ║ l.176: fun f(x) = if x //│ ║ ^ //│ ║ l.177: foo(A) then a -//│ ║ ^^^^^^^^^^^^^^^ -//│ ║ l.178: bar(B) then b -//│ ╙── ^^^^^^^^^^^^^^^ +//│ ╙── ^^ :pe @@ -190,10 +188,10 @@ fun f(x) = if x is 0 then "a" is 1 then "b" //│ ╔══[PARSE ERROR] Expected start of statement in this position; found 'is' keyword instead -//│ ║ l.191: is 1 then "b" +//│ ║ l.189: is 1 then "b" //│ ╙── ^^ //│ ╔══[PARSE ERROR] Expected end of input; found literal instead -//│ ║ l.191: is 1 then "b" +//│ ║ l.189: is 1 then "b" //│ ╙── ^ //│ = [Function: f] diff --git a/hkmc2/shared/src/test/mlscript/basics/RefinedClasses.mls b/hkmc2/shared/src/test/mlscript/basics/RefinedClasses.mls index 1b4d99a8e..e912867d7 100644 --- a/hkmc2/shared/src/test/mlscript/basics/RefinedClasses.mls +++ b/hkmc2/shared/src/test/mlscript/basics/RefinedClasses.mls @@ -2,31 +2,33 @@ :todo class Foo { } -//│ ═══[ERROR] Expected a valid definition head, found block instead +//│ ╔══[ERROR] Invalid class definition head: unexpected block in this position +//│ ║ l.4: class Foo { } +//│ ╙── ^^^ :todo class Foo() { val x = 1 } //│ ╔══[PARSE ERROR] Expected end of input; found curly brace section instead -//│ ║ l.8: class Foo() { -//│ ║ ^ -//│ ║ l.9: val x = 1 -//│ ║ ^^^^^^^^^^^ -//│ ║ l.10: } +//│ ║ l.10: class Foo() { +//│ ║ ^ +//│ ║ l.11: val x = 1 +//│ ║ ^^^^^^^^^^^ +//│ ║ l.12: } //│ ╙── ^ :todo class Foo() val x = 1 //│ ╔══[PARSE ERROR] Expected end of input; found indented block instead -//│ ║ l.21: val x = 1 +//│ ║ l.23: val x = 1 //│ ╙── ^^ :todo class Bar { val x: Int } //│ ╔══[PARSE ERROR] Expected end of input; found curly brace section instead -//│ ║ l.27: class Bar { val x: Int } +//│ ║ l.29: class Bar { val x: Int } //│ ╙── ^^^^^^^^^^^^^^ :todo diff --git a/hkmc2/shared/src/test/mlscript/basics/StrTest.mls b/hkmc2/shared/src/test/mlscript/basics/StrTest.mls index 40a850f63..00c914c8f 100644 --- a/hkmc2/shared/src/test/mlscript/basics/StrTest.mls +++ b/hkmc2/shared/src/test/mlscript/basics/StrTest.mls @@ -21,7 +21,7 @@ concat of //│ = 'ab' (~)("a") -//│ = 'a' +//│ = 'aundefined' ~"a" //│ = 'a' diff --git a/hkmc2/shared/src/test/mlscript/basics/WeirdCalls.mls b/hkmc2/shared/src/test/mlscript/basics/WeirdCalls.mls index 8e92d728c..9406418fd 100644 --- a/hkmc2/shared/src/test/mlscript/basics/WeirdCalls.mls +++ b/hkmc2/shared/src/test/mlscript/basics/WeirdCalls.mls @@ -14,8 +14,12 @@ print "A" ) //│ ╔══[ERROR] Illegal juxtaposition right-hand side. +//│ ║ l.13: ( +//│ ║ ^ //│ ║ l.14: "A" -//│ ╙── ^^^ +//│ ║ ^^^^^^^ +//│ ║ l.15: ) +//│ ╙── ^^^ //│ = [Function: print] :pe @@ -24,18 +28,18 @@ print of "A" ) //│ ╔══[PARSE ERROR] Expected an expression; found new line instead -//│ ║ l.22: print of +//│ ║ l.26: print of //│ ║ ^ -//│ ║ l.23: ( +//│ ║ l.27: ( //│ ╙── :pe print of ("A") //│ ╔══[PARSE ERROR] Expected an expression; found new line instead -//│ ║ l.33: print of +//│ ║ l.37: print of //│ ║ ^ -//│ ║ l.34: ("A") +//│ ║ l.38: ("A") //│ ╙── print of @@ -50,15 +54,15 @@ print of "A" ) //│ ╔══[PARSE ERROR] Mistmatched closing indentation -//│ ║ l.50: "A" +//│ ║ l.54: "A" //│ ║ ^ -//│ ║ l.51: ) +//│ ║ l.55: ) //│ ║ //│ ╟── does not correspond to opening parenthesis -//│ ║ l.49: ( +//│ ║ l.53: ( //│ ╙── ^ //│ ╔══[PARSE ERROR] Unexpected closing parenthesis -//│ ║ l.51: ) +//│ ║ l.55: ) //│ ╙── ^ //│ > A diff --git a/hkmc2/shared/src/test/mlscript/bbml/bbRec.mls b/hkmc2/shared/src/test/mlscript/bbml/bbRec.mls index ada02c5f2..8df5e3c4e 100644 --- a/hkmc2/shared/src/test/mlscript/bbml/bbRec.mls +++ b/hkmc2/shared/src/test/mlscript/bbml/bbRec.mls @@ -5,7 +5,10 @@ :fixme // parsing fun f x = f -//│ ╔══[ERROR] Function definition shape not yet supported for x +//│ ╔══[ERROR] Invalid function definition head: unexpected identifier in this position +//│ ║ l.7: fun f x = f +//│ ╙── ^ +//│ ╔══[ERROR] Function definition shape not yet supported for f //│ ║ l.7: fun f x = f //│ ╙── ^ //│ Type: ⊤ @@ -23,7 +26,7 @@ f :todo fun f(x) = f(x.a) //│ ╔══[ERROR] Term shape not yet supported by BbML: Sel(Ref(x),Ident(a)) -//│ ║ l.24: fun f(x) = f(x.a) +//│ ║ l.27: fun f(x) = f(x.a) //│ ╙── ^^^ //│ Type: ⊤ @@ -34,7 +37,7 @@ class Foo[A](a: A) :todo proper error Foo(123) //│ ╔══[ERROR] Variable not found: Foo -//│ ║ l.35: Foo(123) +//│ ║ l.38: Foo(123) //│ ╙── ^^^ //│ Type: ⊥ @@ -46,7 +49,7 @@ new Foo(123) :todo proper error fun f(x) = f(Foo.a(x)) //│ ╔══[ERROR] Term shape not yet supported by BbML: Sel(SynthSel(Ref(globalThis:block#5),Ident(Foo)),Ident(a)) -//│ ║ l.47: fun f(x) = f(Foo.a(x)) +//│ ║ l.50: fun f(x) = f(Foo.a(x)) //│ ╙── ^^^^^ //│ Type: ⊤ diff --git a/hkmc2/shared/src/test/mlscript/codegen/BadFunctions.mls b/hkmc2/shared/src/test/mlscript/codegen/BadFunctions.mls index 32f2622d3..000ad84fb 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/BadFunctions.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/BadFunctions.mls @@ -6,5 +6,8 @@ fun (let) oops = 1 //│ ╔══[PARSE ERROR] Expected expression after 'let' binding keyword; found end of input instead //│ ║ l.5: fun (let) oops = 1 //│ ╙── ^ +//│ ╔══[ERROR] This is not a valid symbolic name +//│ ║ l.5: fun (let) oops = 1 +//│ ╙── ^ diff --git a/hkmc2/shared/src/test/mlscript/codegen/BadOpen.mls b/hkmc2/shared/src/test/mlscript/codegen/BadOpen.mls index 4807000aa..808bb7f35 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/BadOpen.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/BadOpen.mls @@ -5,20 +5,28 @@ module Foo with val x = 1 +:e (open Foo { x }) +//│ ╔══[ERROR] Illegal position for 'open' statement. +//│ ║ l.9: (open Foo { x }) +//│ ╙── ^^^^^^^^^ +:e (((open Foo { x }))) +//│ ╔══[ERROR] Illegal position for 'open' statement. +//│ ║ l.15: (((open Foo { x }))) +//│ ╙── ^^^^^^^^^ :e (open Foo { x }) + 1 //│ ╔══[ERROR] Illegal position for 'open' statement. -//│ ║ l.13: (open Foo { x }) + 1 -//│ ╙── ^^^^^^^ +//│ ║ l.21: (open Foo { x }) + 1 +//│ ╙── ^^^^^^^^^ :e open Foo { y } //│ ╔══[ERROR] Module 'Foo' does not contain member 'y' -//│ ║ l.19: open Foo { y } +//│ ║ l.27: open Foo { y } //│ ╙── ^ :sjs @@ -33,7 +41,7 @@ val Oops = "oops" :e open Oops //│ ╔══[ERROR] Wildcard 'open' not supported for this kind of symbol. -//│ ║ l.34: open Oops +//│ ║ l.42: open Oops //│ ╙── ^^^^ diff --git a/hkmc2/shared/src/test/mlscript/codegen/Bindings.mls b/hkmc2/shared/src/test/mlscript/codegen/Bindings.mls index 03a52e09a..e29456460 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/Bindings.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/Bindings.mls @@ -68,20 +68,23 @@ let x += 1 = 0 in x //│ ╙── ^^^^^^^^^^ +:e (let x = 1) -//│ x = 1 +//│ ╔══[ERROR] Expected a body for let bindings in expression position +//│ ║ l.72: (let x = 1) +//│ ╙── ^^^^^ :e (let x = 1) + 1 //│ ╔══[ERROR] Expected a body for let bindings in expression position -//│ ║ l.75: (let x = 1) + 1 +//│ ║ l.78: (let x = 1) + 1 //│ ╙── ^^^^^ //│ = 1 :e (let f(x) = x) + 1 //│ ╔══[ERROR] Expected a body for let bindings in expression position -//│ ║ l.82: (let f(x) = x) + 1 +//│ ║ l.85: (let f(x) = x) + 1 //│ ╙── ^^^^^^^^ //│ = 1 diff --git a/hkmc2/shared/src/test/mlscript/codegen/FunnyOpen.mls b/hkmc2/shared/src/test/mlscript/codegen/FunnyOpen.mls index a2275a9e1..e151adc67 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/FunnyOpen.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/FunnyOpen.mls @@ -37,21 +37,25 @@ Mod.|> //│ /!!!\ Uncaught error: scala.MatchError: App(Ident(|>),Tup(List(IntLit(1), Ident(x)))) (of class hkmc2.syntax.Tree$App) -:fixme +:pe +:e open Mod { |> } //│ ╔══[PARSE ERROR] Expected start of statement in this position; found end of input instead -//│ ║ l.41: open Mod { |> } +//│ ║ l.42: open Mod { |> } //│ ╙── ^ //│ ╔══[ERROR] Illegal 'open' statement shape. -//│ ║ l.41: open Mod { |> } +//│ ║ l.42: open Mod { |> } //│ ╙── ^^^^^^^^^ +:e open Mod { (|>) } +//│ ╔══[ERROR] Illegal 'open' statement element. +//│ ║ l.52: open Mod { (|>) } +//│ ╙── ^^^^ -:fixme 12 |> print -//│ ═══[RUNTIME ERROR] TypeError: this.Mod.|> is not a function +//│ > 12 open Mod { print, |> } diff --git a/hkmc2/shared/src/test/mlscript/codegen/Juxtapositions.mls b/hkmc2/shared/src/test/mlscript/codegen/Juxtapositions.mls index 5da172c6b..dce787218 100644 --- a/hkmc2/shared/src/test/mlscript/codegen/Juxtapositions.mls +++ b/hkmc2/shared/src/test/mlscript/codegen/Juxtapositions.mls @@ -91,7 +91,7 @@ add(2) 42 { add(2) { inc() } } //│ ╔══[ERROR] Illegal juxtaposition right-hand side. //│ ║ l.91: 42 { add(2) { inc() } } -//│ ╙── ^^^^^^^^^^^^^^ +//│ ╙── ^^^^^^^^^^^^^^^^ //│ = 42 2 * 2 @@ -133,7 +133,7 @@ inc(2) * 2 //│ ║ l.130: inc() //│ ║ ^^^^^ //│ ║ l.131: add(2) -//│ ╙── ^^^^^^^^^^ +//│ ╙── ^^^^ //│ = 42 diff --git a/hkmc2/shared/src/test/mlscript/parser/Block.mls b/hkmc2/shared/src/test/mlscript/parser/Block.mls index d98d8fd49..8d8f3785c 100644 --- a/hkmc2/shared/src/test/mlscript/parser/Block.mls +++ b/hkmc2/shared/src/test/mlscript/parser/Block.mls @@ -63,7 +63,7 @@ let a = 1, 2 let a = (1, 2) //│ Parsed: -//│ LetLike(keyword 'let',Ident(a),Some(Block(List(IntLit(1), IntLit(2)))),None) +//│ LetLike(keyword 'let',Ident(a),Some(Bra(Round,Block(List(IntLit(1), IntLit(2))))),None) let a = { 1, 2 } //│ Parsed: @@ -80,7 +80,7 @@ let a = 1 in 2, 3 let a = 1 in (2, 3) //│ Parsed: -//│ LetLike(keyword 'let',Ident(a),Some(IntLit(1)),Some(Block(List(IntLit(2), IntLit(3))))) +//│ LetLike(keyword 'let',Ident(a),Some(IntLit(1)),Some(Bra(Round,Block(List(IntLit(2), IntLit(3)))))) let a = 1 in { 2, 3 } //│ Parsed: diff --git a/hkmc2/shared/src/test/mlscript/parser/BoolOps.mls b/hkmc2/shared/src/test/mlscript/parser/BoolOps.mls index 3d32d741d..bdc34bb1d 100644 --- a/hkmc2/shared/src/test/mlscript/parser/BoolOps.mls +++ b/hkmc2/shared/src/test/mlscript/parser/BoolOps.mls @@ -19,10 +19,10 @@ a or b and x or d (a and b) or (x and d) //│ Parsed: -//│ InfixApp(InfixApp(Ident(a),keyword 'and',Ident(b)),keyword 'or',InfixApp(Ident(x),keyword 'and',Ident(d))) +//│ InfixApp(Bra(Round,InfixApp(Ident(a),keyword 'and',Ident(b))),keyword 'or',Bra(Round,InfixApp(Ident(x),keyword 'and',Ident(d)))) a and (b or x) and d //│ Parsed: -//│ InfixApp(InfixApp(Ident(a),keyword 'and',InfixApp(Ident(b),keyword 'or',Ident(x))),keyword 'and',Ident(d)) +//│ InfixApp(InfixApp(Ident(a),keyword 'and',Bra(Round,InfixApp(Ident(b),keyword 'or',Ident(x)))),keyword 'and',Ident(d)) diff --git a/hkmc2/shared/src/test/mlscript/parser/Of.mls b/hkmc2/shared/src/test/mlscript/parser/Of.mls index 1d81d1c56..28bf95c09 100644 --- a/hkmc2/shared/src/test/mlscript/parser/Of.mls +++ b/hkmc2/shared/src/test/mlscript/parser/Of.mls @@ -11,7 +11,7 @@ f of 1 f of (1) //│ Parsed: -//│ App(Ident(f),Tup(List(IntLit(1)))) +//│ App(Ident(f),Tup(List(Bra(Round,IntLit(1))))) f of 1, 2 //│ Parsed: @@ -23,7 +23,7 @@ f of 1, 2, 3 f of (1, 2, 3) //│ Parsed: -//│ App(Ident(f),Tup(List(Block(List(IntLit(1), IntLit(2), IntLit(3)))))) +//│ App(Ident(f),Tup(List(Bra(Round,Block(List(IntLit(1), IntLit(2), IntLit(3))))))) f of g(1) //│ Parsed: @@ -35,15 +35,15 @@ f of g of 1 (f of g) of 1 //│ Parsed: -//│ App(App(Ident(f),Tup(List(Ident(g)))),Tup(List(IntLit(1)))) +//│ App(Bra(Round,App(Ident(f),Tup(List(Ident(g))))),Tup(List(IntLit(1)))) (f of g)(1) //│ Parsed: -//│ App(App(Ident(f),Tup(List(Ident(g)))),Tup(List(IntLit(1)))) +//│ App(Bra(Round,App(Ident(f),Tup(List(Ident(g))))),Tup(List(IntLit(1)))) f of (g)(1) //│ Parsed: -//│ App(Ident(f),Tup(List(App(Ident(g),Tup(List(IntLit(1))))))) +//│ App(Ident(f),Tup(List(App(Bra(Round,Ident(g)),Tup(List(IntLit(1))))))) f of diff --git a/hkmc2/shared/src/test/mlscript/parser/Semis.mls b/hkmc2/shared/src/test/mlscript/parser/Semis.mls index 03735e138..234baddc9 100644 --- a/hkmc2/shared/src/test/mlscript/parser/Semis.mls +++ b/hkmc2/shared/src/test/mlscript/parser/Semis.mls @@ -16,7 +16,7 @@ let a = 1; 2 let a = (1; 2) //│ Parsed: -//│ LetLike(keyword 'let',Ident(a),Some(App(Ident(;),Tup(List(IntLit(1), IntLit(2))))),None) +//│ LetLike(keyword 'let',Ident(a),Some(Bra(Round,App(Ident(;),Tup(List(IntLit(1), IntLit(2)))))),None) let a = { 1; 2 } //│ Parsed: @@ -32,7 +32,7 @@ let a = 1 in 2; 3 let a = 1 in (2; 3) //│ Parsed: -//│ LetLike(keyword 'let',Ident(a),Some(IntLit(1)),Some(App(Ident(;),Tup(List(IntLit(2), IntLit(3)))))) +//│ LetLike(keyword 'let',Ident(a),Some(IntLit(1)),Some(Bra(Round,App(Ident(;),Tup(List(IntLit(2), IntLit(3))))))) let a = 1 in { 2; 3 } //│ Parsed: diff --git a/hkmc2/shared/src/test/mlscript/rp/Future.mls b/hkmc2/shared/src/test/mlscript/rp/Future.mls index 16f96cb1e..441a4e14f 100644 --- a/hkmc2/shared/src/test/mlscript/rp/Future.mls +++ b/hkmc2/shared/src/test/mlscript/rp/Future.mls @@ -19,15 +19,15 @@ pattern Rep0(pattern A, B, C)(head) = :todo // Pattern extractions via aliases. pattern Email(name, domain) = (Identifier as name) ~ "@" ~ (Identifier as domain) -//│ ╔══[ERROR] Unrecognized pattern. +//│ ╔══[ERROR] Unrecognized pattern (parenthesis section) //│ ║ l.21: (Identifier as name) ~ "@" ~ (Identifier as domain) -//│ ╙── ^^^^^^^^^^^^^^^^^^ +//│ ╙── ^^^^^^^^^^^^^^^^^^^^ //│ /!!!\ Uncaught error: java.lang.AssertionError: assertion failed :todo // View patterns pattern GreaterThan(value) = case n and n > value then n -//│ ╔══[ERROR] Unrecognized pattern. +//│ ╔══[ERROR] Unrecognized pattern (case) //│ ║ l.29: n and n > value then n //│ ╙── ^^^^^^^^^^^^^^^^^^^^^^ //│ /!!!\ Uncaught error: java.lang.AssertionError: assertion failed diff --git a/hkmc2/shared/src/test/mlscript/rp/RangePatterns.mls b/hkmc2/shared/src/test/mlscript/rp/RangePatterns.mls index 016b206b1..4bfee0701 100644 --- a/hkmc2/shared/src/test/mlscript/rp/RangePatterns.mls +++ b/hkmc2/shared/src/test/mlscript/rp/RangePatterns.mls @@ -52,7 +52,7 @@ pattern UnsignedByte = 0..< 256 //│ ╔══[LEXICAL ERROR] Expect at least one digit after the decimal point //│ ║ l.51: pattern UnsignedByte = 0..< 256 //│ ╙── ^ -//│ ╔══[ERROR] Unrecognized pattern. +//│ ╔══[ERROR] Unrecognized pattern (application) //│ ║ l.51: pattern UnsignedByte = 0..< 256 //│ ╙── ^^^^^^^^ diff --git a/hkmc2/shared/src/test/mlscript/syntax/annotations/Pattern.mls b/hkmc2/shared/src/test/mlscript/syntax/annotations/Pattern.mls index cba666633..e4221a325 100644 --- a/hkmc2/shared/src/test/mlscript/syntax/annotations/Pattern.mls +++ b/hkmc2/shared/src/test/mlscript/syntax/annotations/Pattern.mls @@ -4,6 +4,6 @@ class SomePattern :e // TODO: pattern compilation fun foo(x) = if x is @compile SomePattern then "yes" else "no" -//│ ╔══[ERROR] Unrecognized pattern. +//│ ╔══[ERROR] Unrecognized pattern (annotated) //│ ║ l.6: fun foo(x) = if x is @compile SomePattern then "yes" else "no" //│ ╙── ^^^^^^^^^^^^^^^^^^^ diff --git a/hkmc2/shared/src/test/mlscript/syntax/annotations/Unsupported.mls b/hkmc2/shared/src/test/mlscript/syntax/annotations/Unsupported.mls index 439f00a3e..d74819317 100644 --- a/hkmc2/shared/src/test/mlscript/syntax/annotations/Unsupported.mls +++ b/hkmc2/shared/src/test/mlscript/syntax/annotations/Unsupported.mls @@ -37,7 +37,7 @@ open Str :w (@debug 1 + 2) -//│ ╔══[WARNING] This annotation has no effect +//│ ╔══[WARNING] This annotation has no effect. //│ ║ l.39: (@debug 1 + 2) //│ ║ ^^^^^ //│ ╟── Annotations are not supported on application terms. diff --git a/hkmc2/shared/src/test/mlscript/ucs/future/AppSplits.mls b/hkmc2/shared/src/test/mlscript/ucs/future/AppSplits.mls index ab46b48e4..0b51a0348 100644 --- a/hkmc2/shared/src/test/mlscript/ucs/future/AppSplits.mls +++ b/hkmc2/shared/src/test/mlscript/ucs/future/AppSplits.mls @@ -25,9 +25,7 @@ if foo of 1, //│ ║ l.18: if foo of 1, //│ ║ ^^^^^^^^^ //│ ║ l.19: 0 then "a" -//│ ║ ^^^^^^^^^^^^ -//│ ║ l.20: 1 then "b" -//│ ╙── ^^^^^^^^^^^^ +//│ ╙── ^^ :todo :pe @@ -36,11 +34,9 @@ if foo (0) then "a" (1) then "b" //│ ╔══[ERROR] Unrecognized term split (juxtaposition). -//│ ║ l.35: if foo +//│ ║ l.33: if foo //│ ║ ^^^ -//│ ║ l.36: (0) then "a" -//│ ║ ^^^^^^^^^^^^^^ -//│ ║ l.37: (1) then "b" -//│ ╙── ^^^^^^^^^^^^^^ +//│ ║ l.34: (0) then "a" +//│ ╙── ^^ diff --git a/hkmc2/shared/src/test/mlscript/ucs/future/Or.mls b/hkmc2/shared/src/test/mlscript/ucs/future/Or.mls index 0f14857be..64fba9ef4 100644 --- a/hkmc2/shared/src/test/mlscript/ucs/future/Or.mls +++ b/hkmc2/shared/src/test/mlscript/ucs/future/Or.mls @@ -10,7 +10,7 @@ fun f(a, b) = if a is and b is Some(v') then v + v' or b is Some(v) then v else 0 -//│ ╔══[ERROR] Unrecognized pattern. +//│ ╔══[ERROR] Unrecognized pattern (infix operation) //│ ║ l.9: Some(v) //│ ║ ^^^^^^^ //│ ║ l.10: and b is Some(v') then v + v' diff --git a/hkmc2/shared/src/test/mlscript/ucs/syntax/ConjunctMatches.mls b/hkmc2/shared/src/test/mlscript/ucs/syntax/ConjunctMatches.mls index a1b615e1b..96658f68c 100644 --- a/hkmc2/shared/src/test/mlscript/ucs/syntax/ConjunctMatches.mls +++ b/hkmc2/shared/src/test/mlscript/ucs/syntax/ConjunctMatches.mls @@ -56,15 +56,17 @@ if //│ kw = keyword 'is' //│ rhs = Ident of "A" //│ kw = keyword 'and' -//│ rhs = InfixApp: -//│ lhs = InfixApp: -//│ lhs = Ident of "y" -//│ kw = keyword 'is' -//│ rhs = Ident of "B" -//│ kw = keyword 'and' -//│ rhs = InfixApp: -//│ lhs = Ident of "c" -//│ kw = keyword 'is' -//│ rhs = Ident of "Z" +//│ rhs = Bra: +//│ k = Round +//│ inner = InfixApp: +//│ lhs = InfixApp: +//│ lhs = Ident of "y" +//│ kw = keyword 'is' +//│ rhs = Ident of "B" +//│ kw = keyword 'and' +//│ rhs = InfixApp: +//│ lhs = Ident of "c" +//│ kw = keyword 'is' +//│ rhs = Ident of "Z" //│ kw = keyword 'then' //│ rhs = IntLit of 1 diff --git a/hkmc2/shared/src/test/mlscript/ucs/syntax/SimpleUCS.mls b/hkmc2/shared/src/test/mlscript/ucs/syntax/SimpleUCS.mls index 2ebe9d6d8..85169be25 100644 --- a/hkmc2/shared/src/test/mlscript/ucs/syntax/SimpleUCS.mls +++ b/hkmc2/shared/src/test/mlscript/ucs/syntax/SimpleUCS.mls @@ -215,7 +215,7 @@ fun f(x) = //│ ║ l.212: 0 :: //│ ║ ^^^^ //│ ║ l.213: Nil() then "oh" -//│ ╙── ^^^^^^^^^^^^^^^^^^^^^ +//│ ╙── ^^^^^^ fun f(x) =