mtoohey31/tree-sitter-koka

masks in match expression

Closed this issue · 5 comments

I don't wanna pollute or keep the helix PR from being merged, so I'm creating an issue here instead.

image

Repro:

fun many-rec(p : parser<e,a>, input : sslice, acc : list<a>) : <div|e> (list<a>, sslice)
  match mask<div>
      parse(input, p)
    ParseOk(x, rest) -> many-rec(p, rest, Cons(x, acc))
    ParseError(_, _) -> (acc, input)

pub fun get() : e int { 42 }

I'm only starting to use masks now and I'm not very familiar with them, but this syntax was suggested to be valid by anfelor at koka-lang/koka#397 (comment)

Thanks for opening this here. I'm a little busy with the start of the school semester, but I'll try to get this fixed soon!

I agree that this syntax should be valid. It looks like there's an issue with indented expressions being recognized as blocks in the position used in your example. I've started trying to figure out a fix.

Yet another case of the grammar "spec" being incorrect... it only allows "non-trailing lambda expressions" in match position, and while the expression in your example isn't one of those, the compiler still accepts it 😭.

Should be fixed as of 96d070c.

2024-01-21T20:58:47,821903911-05:00

Yet another case of the grammar "spec" being incorrect... it only allows "non-trailing lambda expressions" in match position, and while the expression in your example isn't one of those, the compiler still accepts it 😭.

Perhaps you can open an issue in the koka repo for the discrepancies you found in the grammar spec. I think these ought to be fixed or flagged as undocumented compiler behavior.