Hi I'm trying to get interitance to work with some methods that use 'var' 
arguments. Here is a complete (but simplified) example that outlines my issue:
    
    
    type
      BaseType = ref object of RootObj
        message: string
      
      InheritedType = ref object of BaseType
        otherprop: int
    
    method thisFunctionDoesntWork(obj: var BaseType) {.base.} =
      echo obj.message
      obj.message = obj.message & " has already been echoed."
    
    method thisFunctionWorks(obj: BaseType) {.base.} =
      echo obj.message
    
    var base = BaseType(
      message: "This is the base type."
    )
    
    var inherited = InheritedType(
      message: "This is the inherited type.",
      otherprop: 10
    )
    
    thisFunctionWorks(base)         # OK
    thisFunctionWorks(inherited)    # OK
    
    thisFunctionDoesntWork(base)        #OK
    thisFunctionDoesntWork(inherited)   #ERROR
    
    
    
    Run
    
    
    issue.nim(28, 23) Error: type mismatch: got <InheritedType>
    but expected one of:
    method thisFunctionDoesntWork(obj: var BaseType)
    first type mismatch at position: 1
    required type for obj: var BaseType
    but expression 'inherited' is of type: InheritedType
    
    expression: thisFunctionDoesntWork(inherited)
    --

What do I need to do to get this to work?

Thanks. 

Reply via email to