swc-project/swc · error

Pattern

Error message

Pattern {:?}

What it means

The ES2015 destructuring pass hit a binding pattern in a variable declarator that it cannot expand into ES5 assignments; it panics naming the pattern with {:?}. Raised in visit_mut_var_decl while lowering `var/let/const` declarators, meaning only some pattern shapes (ident/object/array) are implemented.

Solutions

  1. Inspect the debug-printed pattern to identify which binding form is unsupported
  2. Add a lowering arm for that pattern kind in the destructuring visitor
  3. Ensure earlier passes normalize the pattern before it reaches visit_mut_var_decl
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/swc_ecma_compat_es2015/src/destructuring.rs:470 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17). Data as JSON: /api/errors/d69041f64c278f0a. Report an issue: GitHub.

Appendix: source

Thrown at crates/swc_ecma_compat_es2015/src/destructuring.rs:470

                    // tmp === void 0 ? def_value : tmp
                    Some(Box::new(make_cond_expr(tmp_ident, def_value)))
                } else {
                    Some(def_value)
                };

                let var_decl = VarDeclarator {
                    span,
                    name: *left,
                    init,
                    definite: false,
                };

                let mut var_decls = vec![var_decl];
                var_decls.visit_mut_with(self);
                decls.extend(var_decls);
            }

            _ => unimplemented!("Pattern {:?}", decl),
        }
    }
}

#[fast_path(DestructuringVisitor)]
impl VisitMut for Destructuring {
    noop_visit_mut_type!(fail);

    impl_for_for_stmt!(visit_mut_for_in_stmt, ForInStmt);

    impl_for_for_stmt!(visit_mut_for_of_stmt, ForOfStmt);

    impl_visit_mut_fn!();

    fn visit_mut_module_items(&mut self, n: &mut Vec<ModuleItem>) {
        self.visit_mut_stmt_like(n);
    }

View on GitHub (pinned to 5176682b65)