Sorry, if this sounds a bit idiotic because I started using nim yesterday, so 
my problem is that I created a type such as what follows 
    
    
    import position
    
    type
      Error* = object
        pos_start : position.Position
        pos_end : position.Position
        name: string
        details: string
    
    
    Run

then I went on to create a procedure that returns an instance of this type, 
    
    
    proc IllegalCharacterError*(pos_start : position.Position, pos_end : 
position.Position, details : string) : Error =
      return Error(pos_start: pos_start, pos_end: pos_end, name: 
"IllegalCharacterError", details: details)
    
    
    Run

Now, everything works fine except when I, from another module, try to access 
fields of this returned instance I get error
    
    
    from errors import nil
    from position import nil
    
    var current_char = "2"
    let pos = position.Position(idx: -1, ln: 0, col: -1, fn: fn, ftxt: text)
    let error = errors.IllegalCharacterError(pos, pos, current_char)
    echo error.name
    
    
    Run

The last line is the one that throws the error and following is the error that 
appeared during compilation 
    
    
    Error: undeclared field: 'name' for type errors.Error [declared in 
C:\Users\Mlogix\Desktop\testNim\errors.nim(4, 3)]
    
    
    Run

Thanks, any help would be really appreciated.

Reply via email to