Skip to content

Commit

Permalink
Pass on annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
chengluyu committed Jan 9, 2025
1 parent 82918bc commit e907ad6
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 13 deletions.
4 changes: 1 addition & 3 deletions hkmc2/shared/src/main/scala/hkmc2/syntax/Parser.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 0 additions & 10 deletions hkmc2/shared/src/test/mlscript/syntax/annotations/Unsupported.mls
Original file line number Diff line number Diff line change
Expand Up @@ -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$)

0 comments on commit e907ad6

Please sign in to comment.