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

Type Checking Skips generic functions #19

Open
rtulip opened this issue Jan 19, 2022 · 0 comments
Open

Type Checking Skips generic functions #19

rtulip opened this issue Jan 19, 2022 · 0 comments
Labels
bug Something isn't working Compiler Enhancement Something to make the compiler better

Comments

@rtulip
Copy link
Owner

rtulip commented Jan 19, 2022

Any function that has a with label is skipped during type checking. This means that you don't know if you're generic function is actually sane until you try to call it.

This will be a tricky thing to resolve. Consider the following:

with T
fn generic_putu T do
    cast(int) putu
end

Until we can put bounds on T, we can't actually tell if this function is valid. As such, we may need to do something link:

with T
fn generic_putu T do
    cast(int) putu
where T -> int bool ptr
end

If there isn't a where clause, then it is assumed that T could be any type.

Multiple bounded generics could be handled with multiple where clauses, but it's kinda ugly. Though syntax really isn't the problem at this point.

with A B
fn foo A B do
    // ...
where A -> int bool ptr
where B -> int bool ptr
end
@rtulip rtulip added bug Something isn't working Compiler Enhancement Something to make the compiler better labels Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Compiler Enhancement Something to make the compiler better
Projects
None yet
Development

No branches or pull requests

1 participant