Ok, the problem is that you directly ignore the case when i[0] isn't nnkIdent. 
When this happens you have to recursively find and replace the leftmost i[0] 
node with obj.<what you found> e.g. in a.b.c you replace a with obj.a

so your code becomes
    
    
    proc replaceBase(node: NimNode, obj: NimNode): NimNode =
    
    # later
    if i.kind == nnkAsgn:
      let l = replaceBase(i[0], obj)
      result.add(newAssignment(l, i[1]))
    
    
    Run

Implementing replaceBase will resolve everything.

Again, this might look harder than the string replace, but for most macros you 
need to manipulate nodes in a similar way, e.g. when you add X in call(args) -> 
call(X, args) you can't just add repr-s until you get the result 

Reply via email to