Skip to content

mangler: Private member mangling is broken #14342

@lukaslihotzki

Description

@lukaslihotzki

refs #14218

When there are two classes (without nesting), the second one uses the private member mapping of the first one. Therefore, private member mangling is generally broken, except in the test, which uses the same private identifier for both classes. When changing the second private identifier, the second class is not mangled:

--- a/crates/oxc_minifier/tests/mangler/snapshots/private_member_mangling.snap
+++ b/crates/oxc_minifier/tests/mangler/snapshots/private_member_mangling.snap
@@ -95,7 +96,7 @@ class Foo {
        }
 }

-class A { #field = 1; #method() { return this.#field; } } class B { #field = 2; #method() { return this.#field; } }
+class A { #field = 1; #method() { return this.#field; } } class B { #field2 = 2; #method() { return this.#field2; } }
 class A {
        #e = 1;
        #t() {
@@ -103,8 +104,8 @@ class A {
        }
 }
 class B {
-       #e = 2;
+       #field2 = 2;
        #t() {
-               return this.#e;
+               return this.#field2;
        }
 }

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions