koka-lang / koka

Koka language compiler and interpreter
http://koka-lang.org
Other
3.31k stars 167 forks source link

Handle expression syntax #601

Open TimWhiting opened 3 weeks ago

TimWhiting commented 3 weeks ago

Discussed in https://github.com/koka-lang/koka/discussions/599

Originally posted by **chtenb** October 24, 2024 ```koka pub effect yield ctl yield(elem : a) : () pub fun fin/take(it : () -> |e> (), n : int) : |e> () var count := 0 override handle it ctl yield(elem) if count < n then yield(elem) // Forward the yield to our new yield function count := count + 1 resume(()) else () ``` According to the compiler, this syntax is invalid ``` repro.kk(7, 3): parse error: invalid syntax unexpected "override" expecting ";", "inline", "noinline", "tail", "fip", "fbip", "fun", "val", "var", "with", (basic) expression, "return" or "}" ``` But if I'm not mistaken, the syntax spec in the book says this should work: https://koka-lang.github.io/koka/doc/book.html#sec-handler-expressions Which of the two is right?
TimWhiting commented 3 weeks ago

Even surrounding it by () like the grammar wants still has this error.