Skip to content

Commit

Permalink
fix: added class element parsing scopes to constructor and getter met…
Browse files Browse the repository at this point in the history
…hods
  • Loading branch information
FreeMasen committed May 5, 2023
1 parent 3cadf9a commit 192dbdc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/spanned/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3078,7 +3078,9 @@ where
let id = self.parse_object_property_key()?;
let open_paren = self.expect_punct(Punct::OpenParen)?;
let close_paren = self.expect_punct(Punct::CloseParen)?;
self.add_scope(lexical_names::Scope::FuncTop);
let body = self.parse_method_body(true, false)?;
self.remove_scope();
Ok(PropGet {
keyword_static,
keyword_get,
Expand Down Expand Up @@ -3189,9 +3191,11 @@ where
);
let prev_allow_super_call = self.context.allow_super_call;
self.context.allow_super_call = self.context.allow_super;
self.add_scope(lexical_names::Scope::FuncTop);
let params = self.parse_formal_params()?;
let body = self.parse_method_body(params.simple, params.found_restricted)?;
self.context.allow_super_call = prev_allow_super_call;
self.remove_scope();
let ctor = PropCtor {
keyword: id,
open_paren: params.open_paren,
Expand Down
16 changes: 16 additions & 0 deletions tests/snippets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,22 @@ fn for_lhs() {
run_test("for(var x=(0 in[])in{});", false).unwrap();
}

#[test]
fn class_ctor_scope() {
env_logger::builder().is_test(true).try_init().ok();
run_test("class e {
constructor(t) {}
get a() {
let t;
}
get b() {
let t;
}
}", false).unwrap();
}

#[test]
fn import_default() {
env_logger::builder().is_test(true).try_init().ok();
Expand Down

0 comments on commit 192dbdc

Please sign in to comment.