mirror of
https://github.com/swc-project/swc.git
synced 2024-12-26 07:02:28 +03:00
fix(es/lints): Fix const-assign
in function expressions (#6294)
This commit is contained in:
parent
ff700d8252
commit
a27392a251
@ -31,3 +31,8 @@ b &&= 10;
|
||||
c ||= 10;
|
||||
|
||||
d ??= 10;
|
||||
|
||||
const fn = () => {
|
||||
const e = 100;
|
||||
e = 200;
|
||||
};
|
||||
|
@ -518,3 +518,13 @@
|
||||
: |
|
||||
: `-- cannot reassign
|
||||
`----
|
||||
|
||||
x cannot reassign to a variable declared with `const`
|
||||
,-[36:3]
|
||||
36 | const e = 100;
|
||||
: |
|
||||
: `-- const variable was declared here
|
||||
37 | e = 200;
|
||||
: |
|
||||
: `-- cannot reassign
|
||||
`----
|
||||
|
@ -108,11 +108,13 @@ impl Visit for ConstAssign {
|
||||
program.visit_children_with(self);
|
||||
}
|
||||
|
||||
fn visit_var_decl(&mut self, var_decl: &VarDecl) {
|
||||
fn visit_var_declarator(&mut self, var_declarator: &VarDeclarator) {
|
||||
let old_is_pat_decl = self.is_pat_decl;
|
||||
self.is_pat_decl = true;
|
||||
var_decl.visit_children_with(self);
|
||||
var_declarator.name.visit_with(self);
|
||||
self.is_pat_decl = old_is_pat_decl;
|
||||
|
||||
var_declarator.init.visit_with(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user