A particular case overshadows other cases
Created by: sergi
Compiling the following macro
macro val {
case $var:ident = $expr => {
var $var = $expr
}
case $var:ident = $x:lit .. $y:lit => {
var $var = (function() {
var arr = []
for (var i = $x; i < $y; i++)
arr.push(i)
return arr
})();
}
}
// This snippet below doesn't match
val a = 10;
console.log(a);
// This works nicely
val r = 10 .. 25
console.log(r)
produces the error:
/usr/local/lib/node_modules/sweet.js/lib/sweet.js:189
throw new Error('ASSERT: ' + message);
^
Error: ASSERT: no macro cases matched
at assert (/usr/local/lib/node_modules/sweet.js/lib/sweet.js:189:19)
at Object.macroCases [as transformer] (/usr/local/lib/node_modules/sweet.js/lib/sweet.js:4352:13)
at expand (/usr/local/lib/node_modules/sweet.js/lib/sweet.js:4666:53)
at Object.parse (/usr/local/lib/node_modules/sweet.js/lib/sweet.js:5077:32)
at Object.exports.run (/usr/local/lib/node_modules/sweet.js/lib/sjs.js:19:55)
at Object.<anonymous> (/usr/local/lib/node_modules/sweet.js/bin/sjs:7:23)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
It looks like the case
case $var:ident = $x:lit .. $y:lit => {
var $var = (function() {
var arr = []
for (var i = $x; i < $y; i++)
arr.push(i)
return arr
})();
}
is somehow overshadowing any other cases in the macro.