Skip to content

Commit

Permalink
Merge pull request #86 from rusty-ecma/fix/class-el-scopes
Browse files Browse the repository at this point in the history
fix: added class element parsing scopes to constructor and getter methods
  • Loading branch information
FreeMasen authored May 6, 2023
2 parents d61d566 + 1d7a51e commit 0131461
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,6 @@ jobs:
run: cargo test --release --features=moz_central
env:
RUST_MIN_STACK: 9999999
- name: rust-tarpaulin
uses: actions-rs/tarpaulin@v0.1
env:
RUST_MIN_STACK: 9999999
with:
args: --features=moz_central
- name: Upload to codecov.io
uses: codecov/codecov-action@v3
continue-on-error: true
with:
token: ${{secrets.CODECOV_TOKEN}}
- name: Check syntax
run: cargo fmt --all -- --check
- name: Cache node_modules
uses: actions/cache@v3
with:
Expand Down
4 changes: 4 additions & 0 deletions src/spanned/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3080,7 +3080,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 @@ -3191,9 +3193,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 @@ -1141,6 +1141,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 0131461

Please sign in to comment.