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

weird edge case for arrow functions #4619

Closed
asafigan opened this issue Sep 30, 2016 · 4 comments
Closed

weird edge case for arrow functions #4619

asafigan opened this issue Sep 30, 2016 · 4 comments
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser

Comments

@asafigan
Copy link

I get this error even on the website for babel. (https://babeljs.io/repl/)

these pieces of code work:
const works = ({async}) => {return true}
const alsoWorks = (async=true) => {return true}
const worksAsWell = ([async=true]) => {return true}

but this code doesn't work:
const fails = ({async=true}) => {return true}

even though it works with a function:
const workingFunction = function ({async=true}) {return true}

and any other argument name works:
const differentArgumentName = ({different=true}) => {return true}

So it looks like the error is coming from using the name async with a default value on a deconstructed object in an arrow function's arguments.

Here is a link to an example

@Nolski
Copy link

Nolski commented Sep 30, 2016

Isn't async a reserved keyword? I don't think this should be expected to work.

@asafigan
Copy link
Author

but it works on all the snippets but one. If it shouldn't be used, than none of them should work not just one. Also you can declare variable with the name async.

@danez
Copy link
Member

danez commented Sep 30, 2016

Async is not a reserved word it seems at least I can't see it in the spec, seems our parser is misbehaving here.
http://www.ecma-international.org/ecma-262/6.0/#sec-keywords

@danharper
Copy link
Member

Closing in favour of this in Babylon: babel/babylon#118.

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label May 6, 2018
@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser
Projects
None yet
Development

No branches or pull requests

4 participants