Repository: swc-project/swc
File: crates/swc_ecma_minifier/src/compress/pure/misc.rs (Rust)

Code before:
            if let Some(new_expr) =
                self.compress_array_join_partial(arr.span, &mut arr.elems, &separator)
            {
                self.changed = true;
                report_change!("Compressing array.join() with partial optimization");
                *e = new_expr;
                return;
            }

            if !self.options.unsafe_passes {
                return;
            }

            if arr
                .elems
                .iter()
                .filter_map(|v| v.as_ref())
                .any(|v| match &*v.expr {
                    e if is_pure_undefined(self.expr_ctx, e) => false,
                    Expr::Lit(lit) => !matches!(lit, Lit::Str(..) | Lit::Num(..) | Lit::Null(..)),
                    // This can change behavior if the value is `undefined` or `null`.
                    Expr::Ident(..) => false,
                    // Optional chaining can produce undefined
                    Expr::OptChain(..) => true,
                    // Member expressions might produce undefined
                    Expr::Member(..) => true,
                    _ => true,
                })
            {
                return;
            }

            let sep: Box<Expr> = Lit::Str(Str {
                span: DUMMY_SP,
                raw: None,
                value: separator,
            })
            .into();
            let mut res = Lit::Str(Str {
                span: DUMMY_SP,
                raw: None,
                value: atom!(""),
            })
            .into();

            fn add(to: &mut Expr, right: Box<Expr>) {
                let lhs = to.take();
                *to = BinExpr {
                    span: DUMMY_SP,
                    left: Box::new(lhs),
                    op: op!(bin, "+"),

Review comment (suggestion):
```suggestion
                    Expr::Member(..) => false,
```

Code after:
            if let Some(new_expr) =
                self.compress_array_join_partial(arr.span, &mut arr.elems, &separator)
            {
                self.changed = true;
                report_change!("Compressing array.join() with partial optimization");
                *e = new_expr;
                return;
            }

            if !self.options.unsafe_passes {
                return;
            }

            if arr
                .elems
                .iter()
                .filter_map(|v| v.as_ref())
                .any(|v| match &*v.expr {
                    e if is_pure_undefined(self.expr_ctx, e) => false,
                    Expr::Lit(lit) => !matches!(lit, Lit::Str(..) | Lit::Num(..) | Lit::Null(..)),
                    // All other expressions can potentially be null/undefined
                    _ => true,
                })
            {
                return;
            }

            let sep: Box<Expr> = Lit::Str(Str {
                span: DUMMY_SP,
                raw: None,
                value: separator,
            })
            .into();
            let mut res = Lit::Str(Str {
                span: DUMMY_SP,
                raw: None,
                value: atom!(""),
            })
            .into();

            fn add(to: &mut Expr, right: Box<Expr>) {
                let lhs = to.take();
                *to = BinExpr {
                    span: DUMMY_SP,
                    left: Box::new(lhs),
                    op: op!(bin, "+"),
                    right,
                }
                .into();
            }