Skip to content

Macro argument expansion is wrapped in array #498

@raphinesse

Description

@raphinesse

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions