swc-project/swc · error
Expected ident or function
Error message
Expected ident or function
What it means
Fired while parsing url() modifiers: after the URL value, modifiers may only be idents or functions, but the current token is neither. The parser reports it rather than silently ignoring the bad modifier.
Source
Thrown at crates/swc_css_parser/src/parser/values_and_units/mod.rs:2664
let mut modifiers = Vec::new();
loop {
if is!(self, ")") {
break;
}
match cur!(self) {
tok!("ident") => {
modifiers.push(UrlModifier::Ident(self.parse()?));
}
tok!("function") => {
modifiers.push(UrlModifier::Function(self.parse()?));
}
_ => {
let span = self.input.cur_span();
return Err(Error::new(span, ErrorKind::Expected("ident or function")));
}
}
self.input.skip_ws();
}
expect!(self, ")");
Ok(Url {
span: span!(self, span.lo),
name,
value,
modifiers: Some(modifiers),
})
}
_ => {
unreachable!()
}View on GitHub (pinned to 5176682b65)
Solutions
- Use a valid modifier (an ident or function) after the url
- Remove invalid tokens between the url and its closing ')'
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/swc_css_parser/src/parser/values_and_units/mod.rs:2664 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/ba53bcdcb7f7dce1.
Report an issue: GitHub.