nim-works / phy

compiler and vm experiments
MIT License
3 stars 2 forks source link

lang: `If` expression support #46

Closed saem closed 1 month ago

saem commented 1 month ago

Summary

Adds (If <predicate> <body> <alternative>) expression support, as well as gated logic, via the (If <predicated> <body>) variant.

Details

The body only variants are always treated as unit type expressions, while the exhaustive variants can be expressions of any variety so long as the body and alternative branch types match (the same or subtype).

Implemented If, along with a variety of tests for various failure scenarios. Additionally, added the ability to provide extra message info to the unreachable routine, this is useful for debugging.


Notes for Reviews

zerbina commented 1 month ago

For your info: I've change the title to lang: ..., so that it's consistent with that of the previous source language additions.