This weekend playing with a macro I faced the following problem.

The following code [fails](https://play.nim-lang.org/#ix=2hQj):
    
    
    import macros
    
    proc hello() =
      echo "hola"
    
    macro function() =
      let f = genSym(nskProc, ident="hello")
      result = quote  do:
        proc `f`() =
          echo "hola2"
    expandMacros:
      function
    
    Run

It complains due to the redefinition of hello. In my opinion, that doesn't 
makes sense because the new function name is random.

If I change the line let f = genSym(nskProc, ident="hello") into let f = 
genSym(nskProc, ident="hello2") it works. It creates a new function that looks 
like:
    
    
    proc hello2_3606056() =
      echo ["hola2"]
    
    Run

Is there something that I am missing? 

Reply via email to