Skip to content

Commit

Permalink
refactor(semantic): clean up transform checker
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Aug 22, 2024
1 parent 0d8eff5 commit 7f9bea9
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions crates/oxc_semantic/src/post_transform_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ impl<'s> PostTransformChecker<'s> {
fn check_scopes(&mut self) {
if self.get_static_pair(|data| data.ids.scope_ids.len()).is_mismatch() {
self.errors.push("Scopes mismatch after transform");
return;
}

for scope_ids in self
Expand Down Expand Up @@ -409,6 +410,8 @@ impl<'s> PostTransformChecker<'s> {
if self.remap_scope_ids_sets(&child_ids).is_mismatch() {
self.errors.push_mismatch("Scope children mismatch", scope_ids, child_ids);
}

// NB: Skip checking node IDs match - transformer does not set `AstNodeId`s
}
}

Expand Down Expand Up @@ -484,18 +487,8 @@ impl<'s> PostTransformChecker<'s> {
}

fn check_references(&mut self) {
// Check whether references are valid
for reference_id in self.rebuilt.ids.reference_ids.iter().copied() {
let reference = self.rebuilt.symbols.get_reference(reference_id);
if reference.flags().is_empty() {
self.errors.push(format!(
"Expect ReferenceFlags for IdentifierReference({reference_id:?}) to not be empty"
));
}
}

if self.get_static_pair(|data| data.ids.reference_ids.len()).is_mismatch() {
self.errors.push("ReferenceId mismatch after transform");
self.errors.push("References mismatch after transform");
return;
}

Expand Down

0 comments on commit 7f9bea9

Please sign in to comment.