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

Return the correct type from empty clauses in Pat #14

Open
duncanatt opened this issue Jul 23, 2024 · 0 comments
Open

Return the correct type from empty clauses in Pat #14

duncanatt opened this issue Jul 23, 2024 · 0 comments
Assignees

Comments

@duncanatt
Copy link
Owner

The current implementation generates empty clauses in guard expressions, assuming that the returned value is always of type unit. This is not sufficiently expressive since functions can return any type. The return type of functions is advertised by function specs, which the translation currently does not use.

This needs to be addressed accordingly. Potentially, the solution requires the return type of the function to be propagated to receive expressions in functions, such that this is readily available to the translation pass. This way, the translation can generate the concrete unit datum (e.g. 0 for integers, () for unit, 0.0 for floats, "" for strings, etc.), which would enable Pat to type check successfully. This is only an intermediate solution.

The proper way would be to introduce a general type in Pat e.g. any, which would be the supertype of all Pat types. Alternatively, we can also introduce an undefined value that belongs to all types.

@duncanatt duncanatt self-assigned this Jul 23, 2024
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

No branches or pull requests

1 participant