The Crystal Programming Language Forum

There is a problem with escape regular expression meta characters in the macro code

Demo code (

macro foo(name)

foo "hello"

Expand macro:

crystal tool expand -c


1 expansion found
expansion 1:

# expand macro 'foo' (/storage/code/learn-crystal/
~> /{{hello\}\}/

You can see that there are two left “{” s that have not been escaped.

The issue is that \{{ is actually valid macro syntax in that it allows you to escape a macro expression. Should be able to just double escape the \.

macro foo(name)

I don’t think that explanation fits here. The first opening brace should still be escaped because it can’t be a part of \{{.
This thing looks very suspicious and unexpected. But I haven’t looked deeper into it.

1 Like