Can overloaded functions call each other?

I have this use of an overloaded function set:

comptime Floats = List[Float64]

fn test(x: Float64, y: Float64, z: Float64) -> Bool:
  return x + y < z

fn test(xs: Floats, ys: Floats, z: Float64) -> Bool:
  return all([test(x, y, z) for (x, y) in zip(xs, ys)])

fn main():
  print(test([1.0, 2.0], [3.0, 4.0], 3.0))

But Mojo nightly says the test(x, y, z) call in the second overload is ambiguous.

Is this due to overloaded functions calling each other or some kind of implicit conversion of Float64 to List[Float64]?

This is a bit unfortunate, since Float64 is SIMD[float64, 1] and SIMD values support initialisation from list literals (var v: Float64 = [1]). You could write test(Floats([1.0, 2.0]), [3.0, 4.0], 3.0) instead.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.