Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support More Literals Inside Macros #9811

Merged
merged 1 commit into from
Nov 24, 2020

Conversation

toddsundsted
Copy link
Contributor

Macros don't seem to permit percent literals aside from % and %q. This PR adds support for %Q, %i, %w and %x.

See https://play.crystal-lang.org/#/r/9rgn

macro foo_bar
  %q|#{test}|
end
 
test = "hello, world"
puts foo_bar

Outputs "#{test}".

While https://play.crystal-lang.org/#/r/9rgo

macro foo_bar
  %Q|#{test}|
end
 
test = "hello, world"
puts foo_bar

Prints

There was a problem expanding macro 'foo_bar'


Called macro defined in eval:1:1

Which expanded to:

 > 1 | __temp_24|#{test}|
     ^
Error: unexpected token: EOF

I'd expect it to output "hello, world".

Copy link
Member

@asterite asterite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants