I can't tell you what is going wrong, but apparently there is something going 
wrong. This is what works for me.
    
    
    type Vector[N: static[int], T : int|float] = array[N, int]
    
    proc `+`[N,T](lhs: Vector[N,T], rhs: Vector[N,T]) : Vector[N,T] =
      for i in 0..high(lhs) :
        result[i] = lhs[i] + rhs[i]
    
    let A: Vector[3,int] = [1,2,3]
    let B: Vector[3,int] = [4,5,6]
    
    echo repr(A+B)
    
    

I changed the order of the generic arguments, and I added generic arguments to 
the result type. I haven't fully figured out yet, what happens, when you leave 
out generic argouments on generic types in function arguments, but my 
observation is, that the percedure is implemented generically, a new symbol is 
introduced `Vector` which has the same generic arguments as the argument 
vector. That's why you could leave out the generic arguments on the result type 
in your working examples:
    
    
    proc `+`(lhs, rhs: Vector) : Vector =
      echo Vector.N  # prints 3
      for i in 0..high(lhs) :
        result[i] = lhs[i] + rhs[i]
    

When you want to have for some reason a differently typed generic vector you 
need to put an explicit namespace in front of Vector `mypackage.Vector[13,int]`.

Reply via email to