{.emit: """
    #include <stdlib.h>
    
    typedef struct {
      int x;
    } Parent;
    
    typedef struct {
      int y;
    } Child;
    
    Child *child_new() { return malloc(sizeof(Child)); }
    """.}
    
    type
      Parent {.importc, nodecl, pure, inheritable.} = object
        x: cint
      Child {.importc, nodecl, pure.} = object of Parent
        y: cint
    
    proc newChild(): ptr Child {.importc: "child_new".}
    
    let c = newChild()
    echo c.x              # error: ‘Child’ has no member named ‘Sup’
    let p: ptr Parent = c # error: ‘Child’ has no member named ‘Sup’
    
    
    Run

Reply via email to