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

Reference to class in function in computed key wrongly throws #8776

Open
nicolo-ribaudo opened this issue Mar 25, 2024 · 0 comments
Open

Reference to class in function in computed key wrongly throws #8776

nicolo-ribaudo opened this issue Mar 25, 2024 · 0 comments
Labels
Milestone

Comments

@nicolo-ribaudo
Copy link

Describe the bug

The code below should log 42, but when compiling to es2015 it throws that Class "A" cannot be referenced in computed property keys.

Input code

let capturedPrivateAccess;
class A {
  static #x = 42;
  static [(class {}, capturedPrivateAccess = () => A.#x)];
}
console.log(capturedPrivateAccess());

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": true,
      "decorators": true
    },
    "target": "es2021",
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": true
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.3.100&code=H4sIAAAAAAAAA8tJLVFITiwoKS1KTQkoyixLLEl1TE5OLS625krOSSwuVnBUqOZSUCguSSzJTFZQrlCwVTAxskaIRGtAlFXX6mA3B6hBQ1PB1k7BUU%2B5QjPWmquWKzk%2Frzg%2FJ1UvJz9dA6seDU1Nay4AEGZf35oAAAA%3D&config=H4sIAAAAAAAAA1VPQQ7DIAy79xUo5x22HnbYH%2FYIRNOKCQpKUmlV1b8PWmDbLbEdO946peDFBh5qS2NaoiZGantCeJ1FvxMCskZkQzYKXCornCmhBRs0oAmkJRAX5iD2kwfRNKFkO%2BT%2B2t%2BKFbgQGBM8asfFC7yd7bj%2BPmOCj4TM%2F8Is1fPk2v2Z2JVU8GFYDrKUzEXOD%2B7wFdWwZgyWn%2FXy6LF%2FAOsBZQowAQAA

SWC Info output

No response

Expected behavior

42

Actual behavior

throws at runtime

Version

1.3.100

Additional context

No response

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

Successfully merging a pull request may close this issue.

2 participants