I wanted to put this in the mailing list first because I'm not sure this is a bug. In Node, the following file works fine:
if (1) {
console.log("a");
return;
}
However, if I give it to esprima, with the latest checkout from today, I get:
Illegal return statement
at throwError (/Users/ineeman/work/esprima/esprima.js:1170:21)
at parseReturnStatement (/Users/ineeman/work/esprima/esprima.js:2484:13)
at parseStatement (/Users/ineeman/work/esprima/esprima.js:2752:24)
at parseSourceElement (/Users/ineeman/work/esprima/esprima.js:3025:24)
at parseStatementList (/Users/ineeman/work/esprima/esprima.js:2050:25)
at parseBlock (/Users/ineeman/work/esprima/esprima.js:2065:17)
at parseStatement (/Users/ineeman/work/esprima/esprima.js:2727:24)
at parseIfStatement (/Users/ineeman/work/esprima/esprima.js:2200:22)
at parseStatement (/Users/ineeman/work/esprima/esprima.js:2750:24)
at parseSourceElement (/Users/ineeman/work/esprima/esprima.js:3025:24)
This worked with an older version of Esprima (0.9.8), but seems to not work anymore. There are node packages that use this - could we make this into an option or something, so that we can be lax?
Itay