TritonVM / tasm-lang

Writing tasm with Rust syntax
15 stars 2 forks source link

Thv/option types #56

Closed Sword-Smith closed 6 months ago

Sword-Smith commented 6 months ago

Add support for Option<T> types.

This one got more messy than I had hoped for, as the intermediate AST is rewritten from Expr::Var to Expr::EnumDeclaration in the type checker. I struggled a bit finding the right way of handling multiple instances of None (when multiple Option) are in scope, and this is all I could come up with.

I added some assert statements to bind down the return value that is responsible for the Expr::Var -> Expr::EnumDeclaration rewrite. So at least we check at run-time when I couldn't handle at compile-time.