-
Notifications
You must be signed in to change notification settings - Fork 903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SyntaxError: 'return' outside of function #86
Comments
JavaScript does not allow |
@michaelficarra He is mistaken, UglifyJS does not allow it either. |
Still, for Tern, which needs to parse node code (without the wrapping function kludge being visible), I guess I should add an option to allow this. Implemented in attached patch. I'll push something to Tern to enable it there. |
Thanks for the patch. I was incorrect about Uglify, looks like I had changed that in my fork. I tested Esprima and it doesn't allow it. The TypeScript compiler does allow it. (I'm not just being pedantic, I do actually have a good use case for returning from the top level of the script :)) |
@scriby: I don't think you do. You can always use a top-level IIFE and return from within there. |
I consider it worthwhile to not have to wrap the entire module in a function, which increases indentation level unnecessarily. |
Hi all Any one could help to fix this issue? Regards |
To future googlers, add the |
…g a fork with overriden version (acornjs/acorn#86)
The acorn parser is throwing an error on a node source file with a return statement at the top level. I'm not certain whether this is technically valid or not, but it works in V8 and I know the uglify parser allows it.
The text was updated successfully, but these errors were encountered: