From e907ad68197d93d63b00bb53fadac7dbed0c0522 Mon Sep 17 00:00:00 2001 From: Luyu Cheng Date: Thu, 9 Jan 2025 16:01:45 +0800 Subject: [PATCH] Pass on annotations --- hkmc2/shared/src/main/scala/hkmc2/syntax/Parser.scala | 4 +--- .../test/mlscript/syntax/annotations/Unsupported.mls | 10 ---------- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/hkmc2/shared/src/main/scala/hkmc2/syntax/Parser.scala b/hkmc2/shared/src/main/scala/hkmc2/syntax/Parser.scala index 34aaeabf9..aa5429ac9 100644 --- a/hkmc2/shared/src/main/scala/hkmc2/syntax/Parser.scala +++ b/hkmc2/shared/src/main/scala/hkmc2/syntax/Parser.scala @@ -281,12 +281,10 @@ abstract class Parser( yeetSpaces match case (tok @ BRACKETS(Indent | Curly, toks), loc) :: _ /* if subRule.blkAlt.isEmpty */ => consume - if annotations.nonEmpty then - err((msg"Blocks cannot be annotated" -> S(loc) :: Nil)) prefixRules.kwAlts.get(kw.name) match case S(subRule) if subRule.blkAlt.isEmpty => rec(toks, S(tok.innerLoc), tok.describe).concludeWith { p => - p.blockOf(subRule.map(e => parseRule(CommaPrecNext, exprAlt.rest).map(res => exprAlt.k(e, res)).getOrElse(errExpr)), Nil, allowNewlines) + p.blockOf(subRule.map(e => parseRule(CommaPrecNext, exprAlt.rest).map(res => exprAlt.k(e, res)).getOrElse(errExpr)), annotations, allowNewlines) } ++ blockContOf(rule) case _ => TODO(cur) diff --git a/hkmc2/shared/src/test/mlscript/syntax/annotations/Unsupported.mls b/hkmc2/shared/src/test/mlscript/syntax/annotations/Unsupported.mls index 45a9a3ba7..439f00a3e 100644 --- a/hkmc2/shared/src/test/mlscript/syntax/annotations/Unsupported.mls +++ b/hkmc2/shared/src/test/mlscript/syntax/annotations/Unsupported.mls @@ -90,13 +90,3 @@ id(@Log 5) //│ ║ l.82: @1 + 2 class Qux //│ ╙── ^^^ //│ = 2 - -:todo -class Foo with - @debug - constructor - Bar(qax: Str) -//│ ╔══[PARSE ERROR] Blocks cannot be annotated -//│ ║ l.98: Bar(qax: Str) -//│ ╙── ^^^^ -//│ /!!!\ Uncaught error: scala.NotImplementedError: List() (of class Nil$)