Skip to content
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

Set correct async/generator in IIFE for params #11346

Merged
merged 3 commits into from Mar 29, 2020

Conversation

nicolo-ribaudo
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo commented Mar 28, 2020

Q                       A
Fixed Issues?
Patch: Bug Fix? Yes
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Current behavior:

function* f(a = 1) {
  var a = yield;
}
function* f() {
  let a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
  return function (a) {
    var a = yield;
  }(a);
}

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories i: regression labels Mar 28, 2020
}

function g() {
let a = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default expression could actually throw a sync error, which needs to be caught sand turned into a rejected promise.

@nicolo-ribaudo
Copy link
Member Author

nicolo-ribaudo commented Mar 28, 2020

@ulrichb This should fix your error about await outside of an async function.

@nicolo-ribaudo nicolo-ribaudo added this to the v7.9.5 milestone Mar 28, 2020
@ulrichb
Copy link

ulrichb commented Mar 29, 2020

@nicolo-ribaudo Thank you very much!

Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this PR, but

class C {
  p = async (a = 1) => {
    var a = await a;
    return a;
  }
}

will fail with Unable to transform arrow inside class property given the following settings

{
  "plugins": [
    "transform-parameters",
    "syntax-class-properties"
  ]
}

May leave it as-is since practically no one will leave class properties untranspiled but only parameters.

@nicolo-ribaudo
Copy link
Member Author

The problem is that we don't have a place where we can put a var _this = this declaration.

@nicolo-ribaudo nicolo-ribaudo merged commit c8a8be7 into babel:master Mar 29, 2020
@nicolo-ribaudo nicolo-ribaudo deleted the params-scope-fn-kind branch March 29, 2020 20:01
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jun 29, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants