Hi, I had a bug in some of my nim code and it produced some unusual behaviour. 
It seems that the nim compiler assigns the result of a function before the said 
function has completed. I managed to reproduce it: 
    
    
    import tables
    var values:Table[string,string]
    
    values["item 1"] = "this is item 1"
    values["item 2"] = "this is item 2"
    
    proc addItemToValues():Table[string,string] =
      echo "values variable within function:"
      echo values
      values["item 3"] = "this is item 3"
    
    echo "values variable before function:"
    echo values
    values = addItemToValues()
    echo "values variable after function:"
    echo values
    
    
    Run

produces: 
    
    
    values variable before function:
    {"item 1": "this is item 1", "item 2": "this is item 2"}
    values variable within function:
    {:}
    values variable after function:
    {"item 3": "this is item 3"}
    
    
    Run

I wouldn't consider this a 'bug' in the compiler, because the code is written 
incorrectly, but I am wondering if that is the intended behavior?

I seem to remember reading about this behavior somewhere, but for the life of 
me I cant' find it.

Reply via email to