From e2546e0100683b13c51345bea80affbe6941476a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Thu, 10 Sep 2020 10:48:26 +0900 Subject: [PATCH] resolver: Handle constructor properly (#1054) --- ecmascript/transforms/Cargo.toml | 2 +- ecmascript/transforms/src/resolver.rs | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ecmascript/transforms/Cargo.toml b/ecmascript/transforms/Cargo.toml index e02fc04c65f..b7cd01b505c 100644 --- a/ecmascript/transforms/Cargo.toml +++ b/ecmascript/transforms/Cargo.toml @@ -6,7 +6,7 @@ edition = "2018" license = "Apache-2.0/MIT" name = "swc_ecma_transforms" repository = "https://github.com/swc-project/swc.git" -version = "0.23.5" +version = "0.23.6" [features] const-modules = ["dashmap"] diff --git a/ecmascript/transforms/src/resolver.rs b/ecmascript/transforms/src/resolver.rs index 3724b017048..f5f1a99ae81 100644 --- a/ecmascript/transforms/src/resolver.rs +++ b/ecmascript/transforms/src/resolver.rs @@ -692,13 +692,23 @@ impl<'a> VisitMut for Resolver<'a> { } fn visit_mut_constructor(&mut self, c: &mut Constructor) { + let child_mark = Mark::fresh(self.mark); + + // Child folder + let mut folder = Resolver::new( + child_mark, + Scope::new(ScopeKind::Fn, Some(&self.current)), + None, + self.handle_types, + ); + let old = self.ident_type; self.ident_type = IdentType::Binding; - c.params.visit_mut_with(self); + c.params.visit_mut_with(&mut folder); self.ident_type = old; - c.body.visit_mut_with(self); - c.key.visit_mut_with(self); + c.body.visit_mut_with(&mut folder); + c.key.visit_mut_with(&mut folder); } /// Leftmost one of a member expression should be resolved.