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

Can not infer type parameter when calling generic function from generic function #166

Closed
sharkdp opened this issue Sep 20, 2023 · 0 comments · Fixed by #443
Closed

Can not infer type parameter when calling generic function from generic function #166

sharkdp opened this issue Sep 20, 2023 · 0 comments · Fixed by #443
Labels
bug Something isn't working type-checker

Comments

@sharkdp
Copy link
Owner

sharkdp commented Sep 20, 2023

>>> fn f<T>(y: T, x: T) = atan2(y, x)
error: while type checking
   ┌─ <input:1>:1:23
   │
 1 │ fn f<T>(y: T, x: T) = atan2(y, x)
   │                       ^^^^^ … could not be infered for this function call
   │
   ┌─ Module 'math::functions', File /home/ped1st/.config/numbat/modules/math/functions.nbt:30:4
   │
30 │ fn atan2<T>(y: T, x: T) -> Scalar
   │    ----- The type parameter(s)  in this generic function

Weirdly, it works if we give that type parameter another name:

fn f<S>(y: S, x: S) = atan2(y, x)

So it looks like we need to properly separate namespaces here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working type-checker
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant