I can't seem to get a match
let function = macro {
case infix {$name:ident $[=] | _ ($params ...) { $body ...} } => {
return #{
$name = function $name ($params ...) {
console.log($name.name);
$body ...
}
}
}
}
var add = function (x, y){
return x+y;
}
SyntaxError: [macro] Macro `function` could not be matched with `() {} ...`
11: var add = function (x, y){
^
Macro works fine without var.
I'm aware that 1 non-expr term is allowed in expression position
but var $name:ident $[=]
doesn't work.
If this is impossible with infix is there another way to match a function statement and capture the name of the function?