swc-project/swc · error

swc does not support do expressions

Error message

swc does not support do expressions

What it means

Raised in `Swcify for DoExpression` (swcify/expr.rs:1114). Do expressions (`do { ... }`) are a stage-1 proposal with no representation in swc_ecma_ast, so the impl is a stub returning `Never` that panics unconditionally when a DoExpression node from the Babel AST is swcified. The do-expression node is the triggering input.

Source

Thrown at crates/swc_estree_compat/src/swcify/expr.rs:1114

        swc_ecma_ast::JSXClosingFragment {
            span: ctx.span(&self.base),
        }
    }
}

impl Swcify for BindExpression {
    type Output = Never;

    fn swcify(self, _: &Context) -> Self::Output {
        panic!("swc does not support bind expressions")
    }
}

impl Swcify for DoExpression {
    type Output = Never;

    fn swcify(self, _: &Context) -> Self::Output {
        panic!("swc does not support do expressions")
    }
}

impl Swcify for PipelinePrimaryTopicReference {
    type Output = Never;

    fn swcify(self, _: &Context) -> Self::Output {
        panic!("swc does not support `PipelinePrimaryTopicReference`")
    }
}

impl Swcify for RecordExpression {
    type Output = Never;

    fn swcify(self, _: &Context) -> Self::Output {
        panic!("swc does not support record expressions")
    }
}

View on GitHub (pinned to 5176682b65)

Solutions

  1. Reject inputs containing do expressions with an explicit unsupported-syntax error before swcification
  2. Desugar `do { ... }` to an IIFE in a preprocessing pass before converting
  3. Disable do-expression syntax in the parser configuration that generates the Babel AST
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/swc_estree_compat/src/swcify/expr.rs:1114 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/708cedbdcec9147e. Report an issue: GitHub.