-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
"'return' outside of function" errors in babel 5.x #1298
Copy link
Copy link
Closed
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue
Description
Create a script test.js:
'use strict';
if (true) {
console.log('true');
return;
}Run it with:
$ babel-node test
At version 4.x it works just fine and outputs true.
At version 5.1.10 you get this error:
/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/babel/helpers/parse.js:70
throw err;
^
SyntaxError: /Users/maximilianschmitt/Desktop/test.js: 'return' outside of function (5:2)
3 | if (true) {
4 | console.log('true');
> 5 | return;
| ^
6 | }
7 |
at Parser.pp.raise (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/acorn/src/location.js:68:13)
at Parser.pp.parseReturnStatement (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/acorn/src/statement.js:247:74)
at Parser.pp.parseStatement (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/acorn/src/statement.js:77:19)
at Parser.parseStatement (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/acorn/plugins/flow.js:631:22)
at Parser.pp.parseBlock (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/acorn/src/statement.js:387:21)
at Parser.pp.parseStatement (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/acorn/src/statement.js:93:19)
at Parser.parseStatement (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/acorn/plugins/flow.js:631:22)
at Parser.pp.parseIfStatement (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/acorn/src/statement.js:241:26)
at Parser.pp.parseStatement (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/acorn/src/statement.js:75:19)
at Parser.parseStatement (/usr/local/lib/node_modules/babel/node_modules/babel-core/lib/acorn/plugins/flow.js:631:22)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
outdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issue