Skip to content

Commit

Permalink
resolver: Handle method property correctly (#679)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 authored Feb 19, 2020
1 parent 087e768 commit f79223e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
21 changes: 21 additions & 0 deletions ecmascript/transforms/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,27 @@ impl Fold<ClassMethod> for Resolver<'_> {
}
}

impl Fold<MethodProp> for Resolver<'_> {
fn fold(&mut self, m: MethodProp) -> MethodProp {
let key = m.key.fold_with(self);

let function = {
let child_mark = Mark::fresh(self.mark);

// Child folder
let mut child = Resolver::new(
child_mark,
Scope::new(ScopeKind::Fn, Some(&self.current)),
None,
);

m.function.fold_with(&mut child)
};

MethodProp { key, function, ..m }
}
}

impl<'a> Fold<FnDecl> for Resolver<'a> {
fn fold(&mut self, node: FnDecl) -> FnDecl {
// We don't fold this as Hoister handles this.
Expand Down
11 changes: 11 additions & 0 deletions ecmascript/transforms/src/resolver/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,3 +1053,14 @@ identical!(
var XXX = 1;
"
);

identical!(
issue_678,
"({
foo() {
function bar() {
bar;
}
},
});"
);

0 comments on commit f79223e

Please sign in to comment.