Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Aug 21, 2024
1 parent 9056e5c commit e89129f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions crates/swc_ecma_minifier/src/pass/mangle_names/preserver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use crate::option::MangleOptions;
/// Returns `(preserved, unresolved)`
pub(crate) fn idents_to_preserve<N>(options: MangleOptions, marks: Marks, n: &N) -> FxHashSet<Id>
where
N: VisitWith<Preserver>,
N: for<'a> VisitWith<Preserver<'a>>,
{
let mut v = Preserver {
options,
options: &options,
preserved: Default::default(),
should_preserve: false,
in_top_level: false,
Expand All @@ -23,27 +23,28 @@ where

// Force rename synthesized names
// See https://github.com/swc-project/swc/issues/9468
v.preserved
.retain(|id| id.1.outer().is_descendant_of(top_level_mark));
v.preserved.retain(|id| {
options.reserved.contains(&id.0) || id.1.outer().is_descendant_of(top_level_mark)
});

v.preserved
}
pub(crate) struct Preserver {
options: MangleOptions,
pub(crate) struct Preserver<'a> {
options: &'a MangleOptions,

preserved: FxHashSet<Id>,

should_preserve: bool,
in_top_level: bool,
}

impl Preserver {
impl<'a> Preserver<'a> {
fn is_reserved(&self, ident: &Ident) -> bool {
self.options.reserved.contains(&ident.sym)
}
}

impl Visit for Preserver {
impl<'a> Visit for Preserver<'a> {
noop_visit_type!();

fn visit_block_stmt(&mut self, n: &BlockStmt) {
Expand Down

0 comments on commit e89129f

Please sign in to comment.