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

Macro argument expansion is wrapped in array #498

Open
raphinesse opened this issue Feb 12, 2020 · 0 comments · May be fixed by #505
Open

Macro argument expansion is wrapped in array #498

raphinesse opened this issue Feb 12, 2020 · 0 comments · May be fixed by #505

Comments

@raphinesse
Copy link

raphinesse commented Feb 12, 2020

The docs say:

Macros are expanded at compile time and inserted in places they are used

Now consider this grammar:

id[el]		-> $el		{% id %}

plain_test	-> word		{% id %}
macro_test	-> id[word]	{% id %}

word		-> [\w]:+	{% d => d[0].join("") %}

Given above documentation and grammar I would have expected that macro_test would behave exactly like plain_test . Unfortunately the results differ:

plain_test('asd') ~> 'asd'
macro_test('asd') ~> ['asd']

My current workaround is to manually unwrap the argument expansions in all my macros, like so:

id[el]		-> $el		{% d => d[0][0] %}

However, this is far from ideal.

I'm not sure if this is a code or documentation bug. But I would definitely prefer if macros would not cause this additional wrapping. It gets especially annoying if you have nested macro application.

@raphinesse raphinesse linked a pull request Apr 8, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant