Add option to allow return outside of functions.

Close #288
This commit is contained in:
Mihai Bazon
2014-10-20 18:12:13 +03:00
parent a64bdda9ae
commit f36a1eaa8b
2 changed files with 8 additions and 4 deletions

View File

@@ -609,6 +609,7 @@ function parse($TEXT, options) {
toplevel : null,
expression : false,
html5_comments : true,
bare_returns : false,
});
var S = {
@@ -788,7 +789,7 @@ function parse($TEXT, options) {
return if_();
case "return":
if (S.in_function == 0)
if (S.in_function == 0 && !options.bare_returns)
croak("'return' outside of function");
return new AST_Return({
value: ( is("punc", ";")