I'm trying to do some compile time type introspection, however I'm not getting 
the results I expect. Here is a minimal version of what I'm trying to do:
    
    
    # ---
    import macros
    
    type StructShape[T] = object
      fields: seq[tuple[key, typename: string]]
    
    macro getFields(struct: typedesc): seq[tuple[key, typename: string]] =
      echo "Type declartaion is: ", struct.getTypeImpl.repr
      @[]
    
    proc getShape*(struct: typedesc): StructShape[struct] =
      result.fields = getFields(struct)
    
    # ---
    
    type Foo = object
      bar: string
      baz: int
    
    let shape = getShape(Foo)
    
    
    Run

I'm expecting the call to getTypeImpl to return the full AST of Foo's type 
declaration, but that isn't happening. Instead, I'm getting:
    
    
    Type declartaion is: typeDesc[Foo]
    
    
    Run

I've tried this with 0.19.2 and 0.18.0

Reply via email to