{"action":"opened","number":267,"pull_request":{"url":"https://api.github.com/repos/facebook/regenerator/pulls/267","id":98070121,"html_url":"https://github.com/facebook/regenerator/pull/267","diff_url":"https://github.com/facebook/regenerator/pull/267.diff","patch_url":"https://github.com/facebook/regenerator/pull/267.patch","issue_url":"https://api.github.com/repos/facebook/regenerator/issues/267","number":267,"state":"open","locked":false,"title":"Fix for bug when transform-regenerator is run without transform-es2015-shorthand-properties","user":{"login":"aickin","id":44199,"avatar_url":"https://avatars.githubusercontent.com/u/44199?v=3","gravatar_id":"","url":"https://api.github.com/users/aickin","html_url":"https://github.com/aickin","followers_url":"https://api.github.com/users/aickin/followers","following_url":"https://api.github.com/users/aickin/following{/other_user}","gists_url":"https://api.github.com/users/aickin/gists{/gist_id}","starred_url":"https://api.github.com/users/aickin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aickin/subscriptions","organizations_url":"https://api.github.com/users/aickin/orgs","repos_url":"https://api.github.com/users/aickin/repos","events_url":"https://api.github.com/users/aickin/events{/privacy}","received_events_url":"https://api.github.com/users/aickin/received_events","type":"User","site_admin":false},"body":"I think I found a bug with `transformer-regenerator` when it is used without `transform-es2015-shorthand-properties`. If you take the following input code:\r\n\r\n```\r\nvar o = {\r\n  *foo() {\r\n    return \"foo\";\r\n  }\r\n};\r\n```\r\nand apply **only** `transform-regenerator`, you get:\r\n```\r\nvar o = {\r\n  foo() {\r\n    return regeneratorRuntime.wrap(function _callee$(_context) {\r\n      while (1) switch (_context.prev = _context.next) {\r\n        case 0:\r\n          return _context.abrupt(\"return\", \"foo\");\r\n\r\n        case 1:\r\n        case \"end\":\r\n          return _context.stop();\r\n      }\r\n    }, _callee, this);\r\n  }\r\n};\r\n```\r\nNote that there is a reference to `_callee` at the end, but `_callee` is never defined. This causes a ReferenceError when the code is run.\r\n\r\nIf you add `transform-es2015-shorthand-properties` to the plugin list, you instead get this result:\r\n```\r\nvar o = {\r\n  foo: regeneratorRuntime.mark(function _callee() {\r\n    return regeneratorRuntime.wrap(function _callee$(_context) {\r\n      while (1) switch (_context.prev = _context.next) {\r\n        case 0:\r\n          return _context.abrupt(\"return\", \"foo\");\r\n\r\n        case 1:\r\n        case \"end\":\r\n          return _context.stop();\r\n      }\r\n    }, _callee, this);\r\n  })\r\n};\r\n```\r\nThis version does define `_callee`, and it works.\r\n\r\nI've been experimenting with doing different builds for different browsers, and there are some browser versions that support shorthand properties but not generators. It would be really nice to use `transform-regenerator` without `transform-es2015-shorthand-properties` in this case.\r\n\r\nI made a patch for `transform-regenerator` in this PR that I believe fixes the problem. Since I don't really understand all the intricacies of `regenerator`, I decided to just translate all shorthand generator object methods into non-shorthand object properties with a generator function expression value before the rest of `transform-regenerator` runs. Since generator function expressions transform correctly already, this seems to work.\r\n\r\nI added three test cases: 2 with shorthand object methods and 1 with a boring old object property. The shorthand object method test cases failed with the master branch and work with this PR. All other tests pass on my machine, but I'll watch CI to see how the patch does on other platforms.\r\n\r\nI fully admit I don't understand all this code perfectly, and I welcome any and all feedback on the patch. Thanks for all your work!","created_at":"2016-12-15T01:21:38Z","updated_at":"2016-12-15T01:21:38Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/facebook/regenerator/pulls/267/commits","review_comments_url":"https://api.github.com/repos/facebook/regenerator/pulls/267/comments","review_comment_url":"https://api.github.com/repos/facebook/regenerator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/facebook/regenerator/issues/267/comments","statuses_url":"https://api.github.com/repos/facebook/regenerator/statuses/a248cde8e44ca4c6be4e92ba361918d0e39abbc9","head":{"label":"aickin:master","ref":"master","sha":"a248cde8e44ca4c6be4e92ba361918d0e39abbc9","user":{"login":"aickin","id":44199,"avatar_url":"https://avatars.githubusercontent.com/u/44199?v=3","gravatar_id":"","url":"https://api.github.com/users/aickin","html_url":"https://github.com/aickin","followers_url":"https://api.github.com/users/aickin/followers","following_url":"https://api.github.com/users/aickin/following{/other_user}","gists_url":"https://api.github.com/users/aickin/gists{/gist_id}","starred_url":"https://api.github.com/users/aickin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aickin/subscriptions","organizations_url":"https://api.github.com/users/aickin/orgs","repos_url":"https://api.github.com/users/aickin/repos","events_url":"https://api.github.com/users/aickin/events{/privacy}","received_events_url":"https://api.github.com/users/aickin/received_events","type":"User","site_admin":false},"repo":{"id":75774845,"name":"regenerator","full_name":"aickin/regenerator","owner":{"login":"aickin","id":44199,"avatar_url":"https://avatars.githubusercontent.com/u/44199?v=3","gravatar_id":"","url":"https://api.github.com/users/aickin","html_url":"https://github.com/aickin","followers_url":"https://api.github.com/users/aickin/followers","following_url":"https://api.github.com/users/aickin/following{/other_user}","gists_url":"https://api.github.com/users/aickin/gists{/gist_id}","starred_url":"https://api.github.com/users/aickin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aickin/subscriptions","organizations_url":"https://api.github.com/users/aickin/orgs","repos_url":"https://api.github.com/users/aickin/repos","events_url":"https://api.github.com/users/aickin/events{/privacy}","received_events_url":"https://api.github.com/users/aickin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aickin/regenerator","description":"Source transformer enabling ECMAScript 6 generator functions in JavaScript-of-today.","fork":true,"url":"https://api.github.com/repos/aickin/regenerator","forks_url":"https://api.github.com/repos/aickin/regenerator/forks","keys_url":"https://api.github.com/repos/aickin/regenerator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aickin/regenerator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aickin/regenerator/teams","hooks_url":"https://api.github.com/repos/aickin/regenerator/hooks","issue_events_url":"https://api.github.com/repos/aickin/regenerator/issues/events{/number}","events_url":"https://api.github.com/repos/aickin/regenerator/events","assignees_url":"https://api.github.com/repos/aickin/regenerator/assignees{/user}","branches_url":"https://api.github.com/repos/aickin/regenerator/branches{/branch}","tags_url":"https://api.github.com/repos/aickin/regenerator/tags","blobs_url":"https://api.github.com/repos/aickin/regenerator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aickin/regenerator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aickin/regenerator/git/refs{/sha}","trees_url":"https://api.github.com/repos/aickin/regenerator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aickin/regenerator/statuses/{sha}","languages_url":"https://api.github.com/repos/aickin/regenerator/languages","stargazers_url":"https://api.github.com/repos/aickin/regenerator/stargazers","contributors_url":"https://api.github.com/repos/aickin/regenerator/contributors","subscribers_url":"https://api.github.com/repos/aickin/regenerator/subscribers","subscription_url":"https://api.github.com/repos/aickin/regenerator/subscription","commits_url":"https://api.github.com/repos/aickin/regenerator/commits{/sha}","git_commits_url":"https://api.github.com/repos/aickin/regenerator/git/commits{/sha}","comments_url":"https://api.github.com/repos/aickin/regenerator/comments{/number}","issue_comment_url":"https://api.github.com/repos/aickin/regenerator/issues/comments{/number}","contents_url":"https://api.github.com/repos/aickin/regenerator/contents/{+path}","compare_url":"https://api.github.com/repos/aickin/regenerator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aickin/regenerator/merges","archive_url":"https://api.github.com/repos/aickin/regenerator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aickin/regenerator/downloads","issues_url":"https://api.github.com/repos/aickin/regenerator/issues{/number}","pulls_url":"https://api.github.com/repos/aickin/regenerator/pulls{/number}","milestones_url":"https://api.github.com/repos/aickin/regenerator/milestones{/number}","notifications_url":"https://api.github.com/repos/aickin/regenerator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aickin/regenerator/labels{/name}","releases_url":"https://api.github.com/repos/aickin/regenerator/releases{/id}","deployments_url":"https://api.github.com/repos/aickin/regenerator/deployments","created_at":"2016-12-06T21:53:18Z","updated_at":"2016-12-06T21:53:19Z","pushed_at":"2016-12-15T01:06:45Z","git_url":"git://github.com/aickin/regenerator.git","ssh_url":"git@github.com:aickin/regenerator.git","clone_url":"https://github.com/aickin/regenerator.git","svn_url":"https://github.com/aickin/regenerator","homepage":"http://facebook.github.io/regenerator/","size":3527,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"facebook:master","ref":"master","sha":"ec774948ed1671f338bf0faa060a8c437d8e1fa1","user":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"repo":{"id":13346571,"name":"regenerator","full_name":"facebook/regenerator","owner":{"login":"facebook","id":69631,"avatar_url":"https://avatars.githubusercontent.com/u/69631?v=3","gravatar_id":"","url":"https://api.github.com/users/facebook","html_url":"https://github.com/facebook","followers_url":"https://api.github.com/users/facebook/followers","following_url":"https://api.github.com/users/facebook/following{/other_user}","gists_url":"https://api.github.com/users/facebook/gists{/gist_id}","starred_url":"https://api.github.com/users/facebook/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/facebook/subscriptions","organizations_url":"https://api.github.com/users/facebook/orgs","repos_url":"https://api.github.com/users/facebook/repos","events_url":"https://api.github.com/users/facebook/events{/privacy}","received_events_url":"https://api.github.com/users/facebook/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/facebook/regenerator","description":"Source transformer enabling ECMAScript 6 generator functions in JavaScript-of-today.","fork":false,"url":"https://api.github.com/repos/facebook/regenerator","forks_url":"https://api.github.com/repos/facebook/regenerator/forks","keys_url":"https://api.github.com/repos/facebook/regenerator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/facebook/regenerator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/facebook/regenerator/teams","hooks_url":"https://api.github.com/repos/facebook/regenerator/hooks","issue_events_url":"https://api.github.com/repos/facebook/regenerator/issues/events{/number}","events_url":"https://api.github.com/repos/facebook/regenerator/events","assignees_url":"https://api.github.com/repos/facebook/regenerator/assignees{/user}","branches_url":"https://api.github.com/repos/facebook/regenerator/branches{/branch}","tags_url":"https://api.github.com/repos/facebook/regenerator/tags","blobs_url":"https://api.github.com/repos/facebook/regenerator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/facebook/regenerator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/facebook/regenerator/git/refs{/sha}","trees_url":"https://api.github.com/repos/facebook/regenerator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/facebook/regenerator/statuses/{sha}","languages_url":"https://api.github.com/repos/facebook/regenerator/languages","stargazers_url":"https://api.github.com/repos/facebook/regenerator/stargazers","contributors_url":"https://api.github.com/repos/facebook/regenerator/contributors","subscribers_url":"https://api.github.com/repos/facebook/regenerator/subscribers","subscription_url":"https://api.github.com/repos/facebook/regenerator/subscription","commits_url":"https://api.github.com/repos/facebook/regenerator/commits{/sha}","git_commits_url":"https://api.github.com/repos/facebook/regenerator/git/commits{/sha}","comments_url":"https://api.github.com/repos/facebook/regenerator/comments{/number}","issue_comment_url":"https://api.github.com/repos/facebook/regenerator/issues/comments{/number}","contents_url":"https://api.github.com/repos/facebook/regenerator/contents/{+path}","compare_url":"https://api.github.com/repos/facebook/regenerator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/facebook/regenerator/merges","archive_url":"https://api.github.com/repos/facebook/regenerator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/facebook/regenerator/downloads","issues_url":"https://api.github.com/repos/facebook/regenerator/issues{/number}","pulls_url":"https://api.github.com/repos/facebook/regenerator/pulls{/number}","milestones_url":"https://api.github.com/repos/facebook/regenerator/milestones{/number}","notifications_url":"https://api.github.com/repos/facebook/regenerator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/facebook/regenerator/labels{/name}","releases_url":"https://api.github.com/repos/facebook/regenerator/releases{/id}","deployments_url":"https://api.github.com/repos/facebook/regenerator/deployments","created_at":"2013-10-05T14:37:03Z","updated_at":"2016-12-14T16:41:44Z","pushed_at":"2016-12-15T01:21:38Z","git_url":"git://github.com/facebook/regenerator.git","ssh_url":"git@github.com:facebook/regenerator.git","clone_url":"https://github.com/facebook/regenerator.git","svn_url":"https://github.com/facebook/regenerator","homepage":"http://facebook.github.io/regenerator/","size":3610,"stargazers_count":1790,"watchers_count":1790,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":170,"mirror_url":null,"open_issues_count":37,"forks":170,"open_issues":37,"watchers":1790,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/facebook/regenerator/pulls/267"},"html":{"href":"https://github.com/facebook/regenerator/pull/267"},"issue":{"href":"https://api.github.com/repos/facebook/regenerator/issues/267"},"comments":{"href":"https://api.github.com/repos/facebook/regenerator/issues/267/comments"},"review_comments":{"href":"https://api.github.com/repos/facebook/regenerator/pulls/267/comments"},"review_comment":{"href":"https://api.github.com/repos/facebook/regenerator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/facebook/regenerator/pulls/267/commits"},"statuses":{"href":"https://api.github.com/repos/facebook/regenerator/statuses/a248cde8e44ca4c6be4e92ba361918d0e39abbc9"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":2,"additions":85,"deletions":0,"changed_files":2}}
{"actor":{"display_login":"aickin"}}