swc-project/swc · error
failed to parse input to quote!()
Error message
failed to parse input to quote!()
What it means
The internal_quote proc-macro (behind swc_ecma_quote's quote! macro) failed to parse its input tokens into the QuoteInput structure — the expected form is a string literal plus optional type annotation and variable bindings. This fires at compile time when the quote! invocation's syntax deviates from that grammar, before the embedded source is even parsed into AST nodes.
Source
Thrown at crates/swc_ecma_quote_macros/src/lib.rs:30
ret_type::parse_input_type,
};
mod ast;
mod builder;
mod ctxt;
mod input;
mod ret_type;
/// Don't invoke this macro directly, use the `quote!` macro from
/// `swc_ecma_quote` instead.
#[proc_macro]
pub fn internal_quote(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
let QuoteInput {
src,
as_token: _,
output_type,
vars,
} = syn::parse::<QuoteInput>(input).expect("failed to parse input to quote!()");
let ret_type =
parse_input_type(&src.value(), &output_type).expect("failed to parse input type");
let vars = vars.map(|v| v.1);
let (stmts, vars) = if let Some(vars) = vars {
prepare_vars(&ret_type, vars)
} else {
Default::default()
};
let cx = Ctx { vars };
let expr_for_ast_creation = ret_type.to_code(&cx);
syn::Expr::Block(ExprBlock {
attrs: Default::default(),View on GitHub (pinned to 5176682b65)
Solutions
- Pass a string literal as the macro input, e.g. quote!("const a = 1;")
- Check variable bindings use the documented `src as Type` / var syntax
- Ensure the string is balanced and contains no unescaped quotes
- Use the public quote! macro from swc_ecma_quote instead of invoking internal_quote directly
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/swc_ecma_quote_macros/src/lib.rs:30 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of swc-project/swc@5176682b65 (2026-08-17).
Data as JSON: /api/errors/355e52ad0cef7417.
Report an issue: GitHub.