koka-lang / koka

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

fix evidence vector adjustment for tail resumptive clauses #375

Closed TimWhiting closed 7 months ago

TimWhiting commented 7 months ago

Fixes #374 and #282

Aha, tail recursive operations do not have the correct evidence vector. i.e. in the linked issues, it ends up calling itself or a wrong handler.

In Core/Simplify changing clause-tailN to clause-tail-noyieldN does not work when using operations (at least with the current implementation of clause-tail-noyieldN) - even if those operations do not yield, because the evidence vector is incorrect.

Instead of changing the simplify assumption, I fix the implementation of clause-tail-noyieldN in hnd.kk set and restore the proper evidence vectors.

TimWhiting commented 7 months ago

I additionally added support for operations with up to 8 parameters, and allow tuples up to 8. (Just some other changes that I had laying around waiting for a good PR to go into).

When translating the compiler to Koka I ran into a few places where I needed more than a 5-tuple.