swc-project/swc · error · Error
Unexpected ')' in declaration value
Error message
Unexpected ')' in declaration value
What it means
Fired by the declaration-value validator: a preserved ')' token (or other listed invalid preserved token such as bad string/bad url) appears inside a declaration value where no matching open block exists. Unbalanced closers are a CSS parse error, so the value is reported as invalid.
Source
Thrown at crates/swc_css_parser/src/parser/util.rs:386
&mut self,
component_value: &ComponentValue,
) -> PResult<()> {
let ComponentValue::PreservedToken(preserved_token) = component_value else {
return Ok(());
};
let kind = match preserved_token.token {
Token::BadString { .. } => ErrorKind::Unexpected("bad string in declaration value"),
Token::BadUrl { .. } => ErrorKind::Unexpected("bad url in declaration value"),
Token::RParen => ErrorKind::Unexpected("')' in declaration value"),
Token::RBracket => ErrorKind::Unexpected("']' in declaration value"),
Token::RBrace => ErrorKind::Unexpected("'}' in declaration value"),
Token::Semi => ErrorKind::Unexpected("';' in declaration value"),
Token::Delim { value: '!' } => ErrorKind::Unexpected("'!' in declaration value"),
_ => return Ok(()),
};
Err(Error::new(preserved_token.span, kind))
}
}
pub(super) struct WithCtx<'w, I: 'w + ParserInput> {
inner: &'w mut Parser<I>,
orig_ctx: Ctx,
}
impl<I: ParserInput> Deref for WithCtx<'_, I> {
type Target = Parser<I>;
fn deref(&self) -> &Parser<I> {
self.inner
}
}
impl<I: ParserInput> DerefMut for WithCtx<'_, I> {
fn deref_mut(&mut self) -> &mut Parser<I> {
self.innerView on GitHub (pinned to 5176682b65)
Solutions
- Remove the stray ')' or add the matching opening '(' block
- Rebalance parentheses inside the declaration value
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/swc_css_parser/src/parser/util.rs:386 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/0b900e9137b9d93e.
Report an issue: GitHub.