mirror of
https://github.com/swc-project/swc.git
synced 2024-10-04 20:28:43 +03:00
fix(es/compat): Fix is_setter
in parameters
pass (#7348)
**Description:** x-ref: https://vercel.slack.com/archives/C02HY34AKME/p1682667306929829
This commit is contained in:
parent
11c1f2c7b3
commit
e0de83e862
@ -437,6 +437,33 @@ impl VisitMut for Params {
|
|||||||
self.in_prop = old_in_prop;
|
self.in_prop = old_in_prop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn visit_mut_class_method(&mut self, m: &mut ClassMethod) {
|
||||||
|
if let MethodKind::Setter = m.kind {
|
||||||
|
let f = &mut m.function;
|
||||||
|
|
||||||
|
if f.body.is_none() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let old_in_subclass = self.in_subclass;
|
||||||
|
let old_in_prop = self.in_prop;
|
||||||
|
self.in_subclass = false;
|
||||||
|
self.in_prop = false;
|
||||||
|
|
||||||
|
f.visit_mut_children_with(self);
|
||||||
|
|
||||||
|
let mut body = f.body.take().unwrap();
|
||||||
|
self.visit_mut_fn_like(&mut f.params, &mut body, true);
|
||||||
|
|
||||||
|
f.body = Some(body);
|
||||||
|
|
||||||
|
self.in_subclass = old_in_subclass;
|
||||||
|
self.in_prop = old_in_prop;
|
||||||
|
} else {
|
||||||
|
m.visit_mut_children_with(self);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// same for private prop
|
// same for private prop
|
||||||
fn visit_mut_private_prop(&mut self, prop: &mut PrivateProp) {
|
fn visit_mut_private_prop(&mut self, prop: &mut PrivateProp) {
|
||||||
let old_in_prop = self.in_prop;
|
let old_in_prop = self.in_prop;
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
class Test {
|
||||||
|
set property(value = null) {
|
||||||
|
// oh no, will generate code that is a SyntaxError
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
class Test {
|
||||||
|
set property(value) {
|
||||||
|
if (value === void 0) value = null;
|
||||||
|
// oh no, will generate code that is a SyntaxError
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user