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(es/compat): Chained assignment operator of super props #6319

Merged
merged 3 commits into from Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 19 additions & 0 deletions crates/swc/tests/fixture/issues-6xxx/6309/input/.swcrc
@@ -0,0 +1,19 @@
{
"jsc": {
"parser": {
"syntax": "ecmascript",
"jsx": false
},
"target": "es5",
"loose": false,
"minify": {
"compress": false,
"mangle": false
}
},
"module": {
"type": "es6"
},
"minify": false,
"isModule": true
}
4 changes: 4 additions & 0 deletions crates/swc/tests/fixture/issues-6xxx/6309/input/input.js
@@ -0,0 +1,4 @@
class x {
static x = super.x += super.x += 0;
static y = super.x = super.x += 0;
}
11 changes: 11 additions & 0 deletions crates/swc/tests/fixture/issues-6xxx/6309/output/input.js
@@ -0,0 +1,11 @@
import _class_call_check from "@swc/helpers/src/_class_call_check.mjs";
import _define_property from "@swc/helpers/src/_define_property.mjs";
import _get_prototype_of from "@swc/helpers/src/_get_prototype_of.mjs";
import _set from "@swc/helpers/src/_set.mjs";
import _update from "@swc/helpers/src/_update.mjs";
var x = function x() {
"use strict";
_class_call_check(this, x);
};
_define_property(x, "x", _update(_get_prototype_of(x), "x", x, true)._ += _update(_get_prototype_of(x), "x", x, true)._ += 0);
_define_property(x, "y", _set(_get_prototype_of(x), "x", _update(_get_prototype_of(x), "x", x, true)._ += 0, x, true));
4 changes: 2 additions & 2 deletions crates/swc_ecma_transforms_classes/src/super_field.rs
Expand Up @@ -124,11 +124,11 @@ impl<'a> VisitMut for SuperFieldAccessFolder<'a> {
right,
..
}) if is_assign_to_super_prop(left) => {
right.visit_mut_children_with(self);
right.visit_mut_with(self);
self.visit_mut_super_member_set(n)
}
Expr::Assign(AssignExpr { left, right, .. }) if is_assign_to_super_prop(left) => {
right.visit_mut_children_with(self);
right.visit_mut_with(self);
self.visit_mut_super_member_update(n);
}
Expr::Call(CallExpr {
Expand Down