numbat icon indicating copy to clipboard operation
numbat copied to clipboard

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

Open sharkdp opened this issue 9 months ago • 0 comments

>>> 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.

sharkdp avatar Sep 20 '23 21:09 sharkdp