oxc/crates
overlookmotel 0eadd9f6de fix(transformer/class-properties): create temp var for class where required (#7516)
Fix class properties transform to create a temp var for class when it's required.

Input:

```js
class C {
  static getSelf = () => this;
}
const C2 = C;
C = 123;
assert(C2.getSelf() === C);
```

Output:

```js
var _C;
class C {}
_C = C;
_defineProperty(C, "getSelf", () => _C);
const C2 = C;
C = 123;
assert(C2.getSelf() === C);
```

Previously, temp var wasn't used so code was `_defineProperty(C, "getSelf", () => C);`. `C` is altered later by `C = 123`, so `C2.getSelf()` returned `123`, instead of reference to the class.

The logic around when a temp var is required and when it's not, and when/where it's referenced is ridiculously complicated. So add some debug assert mechanisms to double-check the logic.
2024-12-03 07:46:04 +00:00
..
oxc feat(parser)!: Build ModuleRecord directly in parser (#7546) 2024-11-29 14:50:42 +00:00
oxc_allocator chore: Rust v1.83.0 changes (#7535) 2024-11-29 11:59:45 +08:00
oxc_ast chore(deps): update dependency rust to v1.83.0 (#7537) 2024-11-29 07:25:36 +00:00
oxc_ast_macros release(crates): v0.38.0 (#7490) 2024-11-26 14:38:47 +08:00
oxc_cfg chore: Rust v1.83.0 changes (#7535) 2024-11-29 11:59:45 +08:00
oxc_codegen chore: Rust v1.83.0 changes (#7535) 2024-11-29 11:59:45 +08:00
oxc_data_structures feat(data_structures): add SparseStack::last_mut method (#7528) 2024-11-28 16:39:34 +00:00
oxc_diagnostics release(crates): v0.38.0 (#7490) 2024-11-26 14:38:47 +08:00
oxc_ecmascript test(ecmascript): move tests to oxc_minifier due to cyclic dependency with oxc_parser (#7542) 2024-11-29 09:18:45 +00:00
oxc_estree chore: Rust v1.83.0 changes (#7535) 2024-11-29 11:59:45 +08:00
oxc_isolated_declarations chore: Rust v1.83.0 changes (#7535) 2024-11-29 11:59:45 +08:00
oxc_language_server refactor(linter): add capability of adding semantic data to module record (#7561) 2024-12-01 08:14:43 +00:00
oxc_linter fix(linter): no-unused-expressions false positive with arrow fn expressions (#7585) 2024-12-03 09:48:50 +08:00
oxc_macros feat(linter): allow lint rules with the same name (#7496) 2024-11-27 04:25:05 +00:00
oxc_mangler release(crates): v0.38.0 (#7490) 2024-11-26 14:38:47 +08:00
oxc_minifier test(ecmascript): move tests to oxc_minifier due to cyclic dependency with oxc_parser (#7542) 2024-11-29 09:18:45 +00:00
oxc_parser feat(syntax): add statement span to ImportEntry and ExportEntry (#7583) 2024-12-02 14:20:30 +00:00
oxc_prettier chore(deps): update dependency rust to v1.83.0 (#7537) 2024-11-29 07:25:36 +00:00
oxc_regular_expression chore(deps): update dependency rust to v1.83.0 (#7537) 2024-11-29 07:25:36 +00:00
oxc_semantic refactor(semantic)!: remove ModuleRecord from Semantic (#7548) 2024-11-29 16:30:54 +00:00
oxc_sourcemap release(crates): v0.38.0 (#7490) 2024-11-26 14:38:47 +08:00
oxc_span fix(span): fix clippy warning (#7591) 2024-12-03 02:18:57 +00:00
oxc_syntax feat(syntax): add statement span to ImportEntry and ExportEntry (#7583) 2024-12-02 14:20:30 +00:00
oxc_transformer fix(transformer/class-properties): create temp var for class where required (#7516) 2024-12-03 07:46:04 +00:00
oxc_traverse chore(deps): remove memoffset dependency (#7573) 2024-12-01 23:39:27 +00:00
oxc_wasm refactor(linter): add capability of adding semantic data to module record (#7561) 2024-12-01 08:14:43 +00:00