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

Parser bug: top-level async and generator functions conflict with nested var declarations #857

Closed
bakkot opened this issue Feb 21, 2021 · 1 comment

Comments

@bakkot
Copy link

bakkot commented Feb 21, 2021

Another bug from fuzzing:

async function x() {}
{
  var x;
}

is improperly rejected. The same happens for function* and async function*, but not a plain function(){}, and not if the var x is at the top level of the program or function rather than nested inside of a block or loop header.

This also applies inside functions, as in

function outer() {
  async function x() {}
  {
    var x;
  }
}

Note that this would be the correct behavior at a higher level of nesting. It's only at the top level of programs and functions where function declarations are treated like var declarations for the purposes of determining conflicts.

The relevant part of the spec is TopLevelLexicallyDeclaredNames, which has a special case for HoistableDeclaration, which includes all four kinds of function declaration, not just non-async non-generator functions.

@evanw
Copy link
Owner

evanw commented Feb 21, 2021

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants