Why the following code is failing?
    
    
    proc pt*[N:SomeNumber](x, y, z:N):tuple[x,y,z:float] =
      return (x: x.float, y: y.float, z: z.float)
    
    let t1 = pt(0,0,0)
    let t2 = pt(0.1, 0, 0)
    let t3 = pt(0.1, 0.3, 0)
    let t4 = pt(0, 0.3, 0)       #<----- Why is this failing?
    echo t1
    echo t2
    echo t3
    echo t4
    
    Run

gives the following error:
    
    
    /tmp/ex01.nim(7, 12) Error: type mismatch: got <int literal(0), float64, 
int literal(0)>
    but expected one of:
    proc pt[N: SomeNumber](x, y, z: N): tuple[x, y, z: float]
    first type mismatch at position: 2
    required type for y: N: SomeNumber
    but expression '0.3' is of type: float64
    
    expression: pt(0, 0.3, 0)

Why?

Reply via email to