String to Symbol

The reason is you can’t use non macro variables as an argument to a macro. I.e. when the macro expands it’s working based on the name of variable, not its value because the value of the var is not available at compile time. It would work the way you want if you did to_sym("abc"). Also could do sym.symbolize instead of :{{sym.id}}.

However, what’s the reasoning for wanting to do this? Why not just use a String? It’s usually recommended to avoid symbols as they have essentially no benefit over a String or Enum. See More on Symbols.