{"action":"created","issue":{"url":"https://api.github.com/repos/jquery/esprima/issues/1506","repository_url":"https://api.github.com/repos/jquery/esprima","labels_url":"https://api.github.com/repos/jquery/esprima/issues/1506/labels{/name}","comments_url":"https://api.github.com/repos/jquery/esprima/issues/1506/comments","events_url":"https://api.github.com/repos/jquery/esprima/issues/1506/events","html_url":"https://github.com/jquery/esprima/issues/1506","id":164895554,"number":1506,"title":"Return statement containing newline is incorrectly parsed as two statements","user":{"login":"joepie91","id":1663259,"avatar_url":"https://avatars.githubusercontent.com/u/1663259?v=3","gravatar_id":"","url":"https://api.github.com/users/joepie91","html_url":"https://github.com/joepie91","followers_url":"https://api.github.com/users/joepie91/followers","following_url":"https://api.github.com/users/joepie91/following{/other_user}","gists_url":"https://api.github.com/users/joepie91/gists{/gist_id}","starred_url":"https://api.github.com/users/joepie91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joepie91/subscriptions","organizations_url":"https://api.github.com/users/joepie91/orgs","repos_url":"https://api.github.com/users/joepie91/repos","events_url":"https://api.github.com/users/joepie91/events{/privacy}","received_events_url":"https://api.github.com/users/joepie91/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-11T17:51:39Z","updated_at":"2016-07-11T18:24:06Z","closed_at":"2016-07-11T18:24:06Z","body":"__Version:__ `esprima@2.7.2`\r\n\r\nSample code:\r\n\r\n```js\r\nfunction foo() { return\r\nbar; }\r\n```\r\n\r\nExample results with and without a newline between the `ReturnStatement` and the `Identifier`:\r\n\r\n```js\r\n> console.log(util.inspect(esprima.parse(\"function foo() { return\\nbar; }\").body[0], {colors: true, depth: null}))\r\n{ type: 'FunctionDeclaration',\r\n  id: { type: 'Identifier', name: 'foo' },\r\n  params: [],\r\n  defaults: [],\r\n  body: \r\n   { type: 'BlockStatement',\r\n     body: \r\n      [ { type: 'ReturnStatement', argument: null },\r\n        { type: 'ExpressionStatement',\r\n          expression: { type: 'Identifier', name: 'bar' } } ] },\r\n  generator: false,\r\n  expression: false }\r\n\r\n> console.log(util.inspect(esprima.parse(\"function foo() { return bar; }\").body[0], {colors: true, depth: null}))\r\n{ type: 'FunctionDeclaration',\r\n  id: { type: 'Identifier', name: 'foo' },\r\n  params: [],\r\n  defaults: [],\r\n  body: \r\n   { type: 'BlockStatement',\r\n     body: \r\n      [ { type: 'ReturnStatement',\r\n          argument: { type: 'Identifier', name: 'bar' } } ] },\r\n  generator: false,\r\n  expression: false }\r\n```\r\n\r\nThis is a case I ran into while deobfuscating in-the-wild JS malware, and while Esprima interpreted it as two *separate* statements, Chrome parses this as a single `ReturnStatement` regardless of whether there's a newline or not. I don't know what the spec says about this, but judging from [this page](http://esprima.org/doc/compatibility.html), it might be desirable to bring Esprima's behaviour in line with that of browsers."},"comment":{"url":"https://api.github.com/repos/jquery/esprima/issues/comments/231820934","html_url":"https://github.com/jquery/esprima/issues/1506#issuecomment-231820934","issue_url":"https://api.github.com/repos/jquery/esprima/issues/1506","id":231820934,"user":{"login":"mikesherov","id":364532,"avatar_url":"https://avatars.githubusercontent.com/u/364532?v=3","gravatar_id":"","url":"https://api.github.com/users/mikesherov","html_url":"https://github.com/mikesherov","followers_url":"https://api.github.com/users/mikesherov/followers","following_url":"https://api.github.com/users/mikesherov/following{/other_user}","gists_url":"https://api.github.com/users/mikesherov/gists{/gist_id}","starred_url":"https://api.github.com/users/mikesherov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mikesherov/subscriptions","organizations_url":"https://api.github.com/users/mikesherov/orgs","repos_url":"https://api.github.com/users/mikesherov/repos","events_url":"https://api.github.com/users/mikesherov/events{/privacy}","received_events_url":"https://api.github.com/users/mikesherov/received_events","type":"User","site_admin":false},"created_at":"2016-07-11T18:24:06Z","updated_at":"2016-07-11T18:24:06Z","body":"Thanks for contributing! It is 2 statements due to semicolon insertion. Please see here for proof: https://jsfiddle.net/tywocq5y/\r\n\r\nClosing this issue for now, please let me know if you feel this was closed in error."}}
{"actor":{"display_login":"mikesherov"}}