var f = function () {
match (num1, num2, num3) {
case (Number, Number, Number):
allNums = true;
default:
allNums = false;
}
};
This fails:
const f = function () {
match (num1, num2, num3) {
case (Number, Number, Number):
allNums = true;
default:
allNums = false;
}
};
The error message:
/home/havvy/sweetjs/playground/node_modules/sweet.js/lib/parser.js:5213
throw e;
^
Error: Line 2: Unexpected token {
[... , num3 ) { case ( ...]
at throwError (/home/havvy/sweetjs/playground/node_modules/sweet.js/lib/parser.js:1887:21)
at throwUnexpected (/home/havvy/sweetjs/playground/node_modules/sweet.js/lib/parser.js:1939:9)
at consumeSemicolon (/home/havvy/sweetjs/playground/node_modules/sweet.js/lib/parser.js:1994:13)
at parseStatement (/home/havvy/sweetjs/playground/node_modules/sweet.js/lib/parser.js:3376:9)
at /home/havvy/sweetjs/playground/node_modules/sweet.js/lib/parser.js:4316:38
at parseSourceElement (/home/havvy/sweetjs/playground/node_modules/sweet.js/lib/parser.js:3790:20)
at parseFunctionSourceElements (/home/havvy/sweetjs/playground/node_modules/sweet.js/lib/parser.js:3426:29)
at /home/havvy/sweetjs/playground/node_modules/sweet.js/lib/parser.js:4316:38
at parseConciseBody (/home/havvy/sweetjs/playground/node_modules/sweet.js/lib/parser.js:3382:20)
at parseFunctionExpression (/home/havvy/sweetjs/playground/node_modules/sweet.js/lib/parser.js:3611:16)
The only difference between working and not working is the var token changed to a const token. There's no other macro involved, and the code parses if the match statement is removed. The behavior seems to also ignore depth between the const and the match. E.g., the following also fails.
const f = function () {
var g = function () {
match (num1, num2, num3) {
case (Number, Number, Number):
allNums = true;
default:
allNums = false;
}
}
}
This works:
This fails:
The error message:
The only difference between working and not working is the
var
token changed to aconst
token. There's no other macro involved, and the code parses if the match statement is removed. The behavior seems to also ignore depth between theconst
and thematch
. E.g., the following also fails.