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

Add support for adding type hints to functions #332

Merged
merged 8 commits into from
May 27, 2024
Merged

Add support for adding type hints to functions #332

merged 8 commits into from
May 27, 2024

Conversation

irh
Copy link
Contributor

@irh irh commented May 27, 2024

This PR adds support for type hints on function arguments and on the function's return type.

The >> pipe operator has been replaced with -> to match the function output type syntax, which avoids there being two unique syntax elements related to function output.

Additionally numbers now report their types as Number rather than Int or Float.

#298

irh added 8 commits May 27, 2024 08:10
For type hints to be practically useful for runtime checks, for now they're
going to have to be non-generic to avoid having to worry about (e.g.) checking
every element in a list to see if it matches `List<String>`.

In the future perhaps some strategies will be figured out for efficient runtime
checks, but for now we can simplify the parser and AST by making it clear that
types can't be nested.
Pipe detection was originally moved from the lexer to the parser in
eee1a9c to support parsing generic types,
but given that we're not going to support generic types any time soon I think
it's better to roll back to the simpler implementation.
@irh irh merged commit 4a8a842 into main May 27, 2024
6 checks passed
@irh irh deleted the more-type-checks branch May 27, 2024 14:03
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