Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to see what a Crystal macro expands to?

I've a macro that refuses to work as expected and I was wondering if there was a way to see what it expands to, is there something like macroexpand-1 from lisp in Crystal? If so, how do I use it? Thanks!

like image 502
Sunder Avatar asked Jul 11 '20 17:07

Sunder


1 Answers

Placing {% debug %} at the end of the macro will print it's contents at compile time.

e.g.

macro foo
  ...
  {% debug %}
end
like image 76
Stephie Avatar answered Nov 10 '22 10:11

Stephie