Reputation: 122062
I'm playing around with sweetjs and for the life of me can't figure out why this rule for parameterless multiline skinny arrow syntax isn't matched
Code:
macro -> {
rule infix { () | { $body ... $last:expr } } => {
function( ) {
$body ...;
return $last
}
}
}
var fn = () -> {
var a = 1;
a + 2;
};
expect(fn()).to.equal(3);
results in
SyntaxError: [macro] Macro `-` could not be matched with `> {} ; expect ()...`
10: var fn = () -> {
^
Upvotes: 2
Views: 200
Reputation: 656
Try removing the semi-colon on the last line of the closure, for some reason the sweetjs compiler has trouble with $last and semi-colons.
macro -> {
rule infix { () | { $body ... $last:expr } } => {
function() {
$($body) ...
return $last
}
}
}
var fn = () -> {
var a = 1
a + 2
};
Upvotes: 2