There is simple version to show the problem. 
    
    
    import typetraits
    
    type Foo[T] = ref object
       x: T
    
    proc `@@`*[T](a: T): Foo[T] = new(result); result.x = a
    proc `$`*[T](f: Foo[T]): string = "Foo[" & $f.x & "]"
    
    type Bar[T] = Foo[Foo[T]]
    
    # OOPS
    # Change the Bar[T] to Foo[Foo[T]] will make compiler happy
    proc core[T](vv: Bar[T]): Foo[T] =
       static: echo "In core type of vv is ", name(type(vv))
       
       # OOPS
       # Should be "int" rather than "Foo[system.int]"
       static: echo "In core type of T is ", name(T)
       
       new(result)
       result.x = vv.x.x
    
    when isMainModule:
       let vv = @@(@@5)
       static: echo "In main type of vv is ", name(type(vv))
       
       # OOPS
       # change to "let x = core[int](vv)" will make compiler happy
       let x = core(vv)
       
       echo x
    

Reply via email to