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

Fix block scoping of class declarations #1569

Merged
merged 3 commits into from
Apr 14, 2021

Conversation

devongovett
Copy link
Contributor

This fixes an issue where class declarations were not properly block scoped.

const g = 20;

function baz() {
  {
    class g {}
  }

  return g;
}

was compiling to:

const g1 = 20; // <- this is wrong
function baz() {
    {
        class g1 {}
    }
    return g;  // <- this is wrong
}

This was caused by the resolver hoisting class declarations when it shouldn't. Now they are ignored if within a block statement, just like let/const var declarations.

@kdy1 kdy1 added this to the v1.2.53 milestone Apr 12, 2021
@kdy1 kdy1 merged commit d8a18df into swc-project:master Apr 14, 2021
@swc-project swc-project locked as resolved and limited conversation to collaborators Nov 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants