Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thv/option types #56

Merged
merged 3 commits into from
Jan 3, 2024
Merged

Thv/option types #56

merged 3 commits into from
Jan 3, 2024

Conversation

Sword-Smith
Copy link
Contributor

@Sword-Smith Sword-Smith commented Jan 3, 2024

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.

This is somewhat hacky, and I'm not sure I want to keep it. With this
patch, the AST is rewritten in the type checker such that a literal `None`
is rewritten to a enum variant declaration `Option::None`.

I think we need to handle this case in the type checker, since that's the
only place where the relevant type information is present, but I'm not sure
this handling is good.
@Sword-Smith Sword-Smith merged commit a6d5b37 into master Jan 3, 2024
3 checks passed
@Sword-Smith Sword-Smith deleted the thv/option-types branch January 18, 2024 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant