swc-project/swc · error · Error
Expected 'none' value of an ident token
Error message
Expected 'none' value of an ident token
What it means
Fired while parsing an alpha component (e.g. in rgb()/hsl() color functions): the token must be a number, percentage, math function, or the ident 'none', but none matched. The parser cannot interpret the token as an alpha value.
Source
Thrown at crates/swc_css_parser/src/parser/values_and_units/mod.rs:1547
values.push(ComponentValue::Delimiter(self.parse()?));
self.input.skip_ws();
let alpha_value = self.try_parse_variable_function(
|parser, has_variable_before| match cur!(parser) {
tok!("number") | tok!("percentage") => {
Ok(Some(ComponentValue::AlphaValue(parser.parse()?)))
}
Token::Function { value, .. } if is_math_function(value) => {
Ok(Some(ComponentValue::Function(parser.parse()?)))
}
tok!("ident") if !matches!(&*lower_fname, "device-cmyk") => {
let ident: Box<Ident> = parser.parse()?;
if ident.value.eq_ignore_ascii_case("none") {
Ok(Some(ComponentValue::Ident(ident)))
} else {
Err(Error::new(
ident.span,
ErrorKind::Expected("'none' value of an ident token"),
))
}
}
_ => {
if !has_variable_before {
Err(Error::new(
parser.input.cur_span(),
ErrorKind::Expected(
"percentage, number, function (math functions) or \
ident (with 'none' value) token",
),
))
} else {
Ok(None)
}
}View on GitHub (pinned to 5176682b65)
Solutions
- Use a number (0-1), a percentage, a math function like calc(), or 'none' for the alpha slot
- Fix typos in the alpha value
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/swc_css_parser/src/parser/values_and_units/mod.rs:1547 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/dd148e843e68f394.
Report an issue: GitHub.