And splitting the macro does not help:
    
    
    import macros
    
    const CX = 7
    
    proc genVar(c: string): NimNode {.compiletime.} =
      result = newNimNode(nnkStmtList)
      var
        section = newNimNode(nnkVarSection)
        constDef = newNimNode(nnkIdentDefs)
      constDef.add(newIdentNode("myvar"))
      constDef.add(newEmptyNode())
      constDef.add(newIdentNode("C" & $c))
      section.add(constDef)
      result.add(section)
    
    macro prep(s: string): typed =
      echo "prep"
      genVar($s)
    
    macro t(otherArgs): typed =
      echo "t"
      if myVar == 7:
        echo "GREAT"
    
    template t(s: static[string]): typed =
      prep(s)
      t("ignoreForNow")
    
    t("X")
    
    
    

Reply via email to