{"action":"created","issue":{"url":"https://api.github.com/repos/MatAtBread/fast-async/issues/56","repository_url":"https://api.github.com/repos/MatAtBread/fast-async","labels_url":"https://api.github.com/repos/MatAtBread/fast-async/issues/56/labels{/name}","comments_url":"https://api.github.com/repos/MatAtBread/fast-async/issues/56/comments","events_url":"https://api.github.com/repos/MatAtBread/fast-async/issues/56/events","html_url":"https://github.com/MatAtBread/fast-async/issues/56","id":317677088,"number":56,"title":"Babel v7: Env Preset + nodent breaks in Babel generator","user":{"login":"swernerx","id":145201,"avatar_url":"https://avatars0.githubusercontent.com/u/145201?v=4","gravatar_id":"","url":"https://api.github.com/users/swernerx","html_url":"https://github.com/swernerx","followers_url":"https://api.github.com/users/swernerx/followers","following_url":"https://api.github.com/users/swernerx/following{/other_user}","gists_url":"https://api.github.com/users/swernerx/gists{/gist_id}","starred_url":"https://api.github.com/users/swernerx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swernerx/subscriptions","organizations_url":"https://api.github.com/users/swernerx/orgs","repos_url":"https://api.github.com/users/swernerx/repos","events_url":"https://api.github.com/users/swernerx/events{/privacy}","received_events_url":"https://api.github.com/users/swernerx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2018-04-25T15:22:18Z","updated_at":"2018-04-26T11:45:51Z","closed_at":null,"author_association":"NONE","body":"I have another exception I got in a pretty trivial case.\r\n\r\nCode:\r\n\r\n```js\r\nasync function executeTasks(tasks) {\r\n  for (const taskName of tasks) {\r\n    try {\r\n      await executeCommands()\r\n    } catch (error) {\r\n      console.error(\"Error\")\r\n    }\r\n  }\r\n}\r\n```\r\n\r\nBabelrc:\r\n\r\n```json\r\n{\r\n  \"presets\": [\r\n    [ \"@babel/env\", { \"exclude\": [\"transform-regenerator\", \"transform-async-to-generator\"] } ]\r\n  ],\r\n\r\n  \"plugins\": [\r\n    \"module:./src/transformAsyncToPromises.js\"\r\n  ]\r\n}\r\n```\r\n\r\nCommand Line:\r\n\r\n```\r\nnode_modules/.bin/babel --config-file ./.babelrc-test --no-babelrc async-for-of.js\r\n```\r\n\r\nException:\r\n\r\n```\r\nTypeError: Cannot read property 'length' of undefined\r\n    at Buffer._append (/Users/swerner/Workspace/open-source/babel-preset-edge/node_modules/@babel/generator/lib/buffer.js:115:26)\r\n    at Buffer.append (/Users/swerner/Workspace/open-source/babel-preset-edge/node_modules/@babel/generator/lib/buffer.js:81:10)\r\n    at Generator._append (/Users/swerner/Workspace/open-source/babel-preset-edge/node_modules/@babel/generator/lib/printer.js:202:52)\r\n    at Generator.word (/Users/swerner/Workspace/open-source/babel-preset-edge/node_modules/@babel/generator/lib/printer.js:126:10)\r\n    at Generator.Identifier (/Users/swerner/Workspace/open-source/babel-preset-edge/node_modules/@babel/generator/lib/generators/types.js:43:8)\r\n    at /Users/swerner/Workspace/open-source/babel-preset-edge/node_modules/@babel/generator/lib/printer.js:315:23\r\n    at Buffer.withSource (/Users/swerner/Workspace/open-source/babel-preset-edge/node_modules/@babel/generator/lib/buffer.js:178:28)\r\n    at Generator.withSource (/Users/swerner/Workspace/open-source/babel-preset-edge/node_modules/@babel/generator/lib/printer.js:182:15)\r\n    at Generator.print (/Users/swerner/Workspace/open-source/babel-preset-edge/node_modules/@babel/generator/lib/printer.js:314:10)\r\n    at Generator.printJoin (/Users/swerner/Workspace/open-source/babel-preset-edge/node_modules/@babel/generator/lib/printer.js:382:12)\r\n```\r\n\r\nI modified the generator a bit to catch this case:\r\n\r\n```\r\n  _proto._append = function _append(str, line, column, identifierName, filename) {\r\n    if (this._map && str[0] !== \"\\n\") {\r\n      this._map.mark(this._position.line, this._position.column, line, column, identifierName, filename);\r\n    }\r\n\r\n    // Hot fix\r\n    if (str == null) {\r\n      str = \"[XXXXX]\"\r\n    }\r\n\r\n   ...\r\n```\r\n\r\nGenerated output with fix:\r\n\r\n```js\r\n\"use strict\";\r\n\r\nfunction executeTasks(tasks) {\r\n  return new Promise(function ($return, $error) {\r\n    var $Try_1_Finally = function ($Try_1_Exit) {\r\n      return function ($Try_1_Value) {\r\n        try {\r\n          var $Try_3_Finally = function ($Try_3_Exit) {\r\n            return function ($Try_3_Value) {\r\n              try {\r\n                if (_didIteratorError) {\r\n                  throw _iteratorError;\r\n                }\r\n\r\n                return $Try_3_Exit && $Try_3_Exit.call(this, $Try_3_Value);\r\n              } catch ($boundEx) {\r\n                return $error($boundEx);\r\n              }\r\n            }.bind(this);\r\n          }.bind(this);\r\n\r\n          var $Try_3_Catch = function ($exception_4) {\r\n            try {\r\n              throw $exception_4;\r\n            } catch ($boundEx) {\r\n              return $Try_3_Finally($error)($boundEx);\r\n            }\r\n          }.bind(this);\r\n\r\n          try {\r\n            if (!_iteratorNormalCompletion && _iterator.return != null) {\r\n              _iterator.return();\r\n            }\r\n\r\n            return $Try_3_Finally([XXXXX])();\r\n          } catch ($exception_4) {\r\n            $Try_3_Catch($exception_4)\r\n          }\r\n\r\n          return $Try_1_Exit && $Try_1_Exit.call(this, $Try_1_Value);\r\n        } catch ($boundEx) {\r\n          return $error($boundEx);\r\n        }\r\n      }.bind(this);\r\n    }.bind(this);\r\n\r\n    var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, taskName;\r\n\r\n    _iteratorNormalCompletion = true;\r\n    _didIteratorError = false;\r\n    _iteratorError = undefined;\r\n\r\n    var $Try_1_Post = function () {\r\n      try {\r\n        return $return();\r\n      } catch ($boundEx) {\r\n        return $error($boundEx);\r\n      }\r\n    };\r\n\r\n    var $Try_1_Catch = function (err) {\r\n      try {\r\n        _didIteratorError = true;\r\n        _iteratorError = err;\r\n        return $Try_1_Finally($Try_1_Post)();\r\n      } catch ($boundEx) {\r\n        return $Try_1_Finally($error)($boundEx);\r\n      }\r\n    };\r\n\r\n    try {\r\n      _iterator = tasks[Symbol.iterator]();\r\n      var $Loop_5_trampoline;\r\n\r\n      function $Loop_5_step() {\r\n        _iteratorNormalCompletion = true;\r\n        return $Loop_5;\r\n      }\r\n\r\n      function $Loop_5() {\r\n        if (!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) {\r\n          taskName = _step.value;\r\n\r\n          var $Try_2_Post = function () {\r\n            try {\r\n              return $Loop_5_step;\r\n            } catch ($boundEx) {\r\n              return $Try_1_Catch($boundEx);\r\n            }\r\n          };\r\n\r\n          var $Try_2_Catch = function (error) {\r\n            try {\r\n              console.error(\"Error\");\r\n              return $Try_2_Post();\r\n            } catch ($boundEx) {\r\n              return $Try_1_Catch($boundEx);\r\n            }\r\n          };\r\n\r\n          try {\r\n            return Promise.resolve(executeCommands()).then(function ($await_7) {\r\n              try {\r\n                return $Try_2_Post();\r\n              } catch ($boundEx) {\r\n                return $Try_2_Catch($boundEx);\r\n              }\r\n            }, $Try_2_Catch);\r\n          } catch (error) {\r\n            $Try_2_Catch(error)\r\n          }\r\n        } else return [1];\r\n      }\r\n\r\n      return ($Loop_5_trampoline = function (q) {\r\n        while (q) {\r\n          if (q.then) return void q.then($Loop_5_trampoline, $Try_1_Catch);\r\n\r\n          try {\r\n            if (q.pop) {\r\n              if (q.length) return q.pop() ? $Loop_5_exit.call(this) : q;else q = $Loop_5_step;\r\n            } else q = q.call(this);\r\n          } catch (_exception) {\r\n            return $Try_1_Catch(_exception);\r\n          }\r\n        }\r\n      }.bind(this))($Loop_5);\r\n\r\n      function $Loop_5_exit() {\r\n        return $Try_1_Finally($Try_1_Post)();\r\n      }\r\n    } catch (err) {\r\n      $Try_1_Catch(err)\r\n    }\r\n  });\r\n}\r\n```\r\n\r\nThe problematic code is at line 35:\r\n\r\n```js\r\n          try {\r\n            if (!_iteratorNormalCompletion && _iterator.return != null) {\r\n              _iterator.return();\r\n            }\r\n\r\n            return $Try_3_Finally([XXXXX])();\r\n          } catch ($exception_4) {\r\n            $Try_3_Catch($exception_4)\r\n          }\r\n```\r\n\r\nDo you have any idea what's wrong?"},"comment":{"url":"https://api.github.com/repos/MatAtBread/fast-async/issues/comments/384611166","html_url":"https://github.com/MatAtBread/fast-async/issues/56#issuecomment-384611166","issue_url":"https://api.github.com/repos/MatAtBread/fast-async/issues/56","id":384611166,"user":{"login":"swernerx","id":145201,"avatar_url":"https://avatars0.githubusercontent.com/u/145201?v=4","gravatar_id":"","url":"https://api.github.com/users/swernerx","html_url":"https://github.com/swernerx","followers_url":"https://api.github.com/users/swernerx/followers","following_url":"https://api.github.com/users/swernerx/following{/other_user}","gists_url":"https://api.github.com/users/swernerx/gists{/gist_id}","starred_url":"https://api.github.com/users/swernerx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/swernerx/subscriptions","organizations_url":"https://api.github.com/users/swernerx/orgs","repos_url":"https://api.github.com/users/swernerx/repos","events_url":"https://api.github.com/users/swernerx/events{/privacy}","received_events_url":"https://api.github.com/users/swernerx/received_events","type":"User","site_admin":false},"created_at":"2018-04-26T11:45:51Z","updated_at":"2018-04-26T11:45:51Z","author_association":"NONE","body":"What do you mean by disabling?\r\n\r\nI am updating a generally used preset. I don't think I can communicate to all why for-of loops with await shouldn't be used. So it's not only about me."}}
{"actor":{"display_login":"swernerx"}}