Silent overwrite possible when using list macro replacment
Currently, it is possible that macros are not substituted reliably when the list macro replacement form is used. Consider the following example:
---
metadata:
crawler-version: 0.3.1
macros:
- !defmacro
name: one_macro
params:
a: 25
definition:
macro_sub:
b: $a
another_param: 3
- !defmacro
name: test_macrodef
params: {}
definition:
macro_top: !macro
one_macro:
- a: 17
- a: 98
---
extroot: !macro
test_macrodef:
The expectation would be that the "one_macro" is applied to times, creating two entries in "macro_top". However, only one of them remains, because the definition of the replacement does not use one of the macro's parameters for making two subsequent replacements on the same level distinguishable... both will be named "macro_sub".
The solution is of course to include one of the parameters of the macro in the name, e.g.:
---
metadata:
crawler-version: 0.3.1
macros:
- !defmacro
name: one_macro
params:
a: 25
definition:
macro_sub_$a:
b: $a
another_param: 3
- !defmacro
name: test_macrodef
params: {}
definition:
macro_top: !macro
one_macro:
- a: 17
- a: 98
---
extroot: !macro
test_macrodef:
... which will lead to the creation of two separate entries.
I think we should at least throw a warning or even raise an error, because this behavior might be unnoticed by users.
Edited by Alexander Schlemmer