swc-project/swc · error · Error
Unexpected value
Error message
Unexpected value
What it means
Fired while parsing math/calc-style function values (calc, sin, cos, ...): after the single calc-sum argument, additional tokens remain before ')'. These functions accept exactly one argument, so trailing content (often a missing comma for multi-argument functions) is reported as unexpected.
Source
Thrown at crates/swc_css_parser/src/parser/values_and_units/mod.rs:213
let mut values = Vec::new();
let lower_fname = function_name.to_ascii_lowercase();
match &*lower_fname {
"calc" | "-moz-calc" | "-webkit-calc" | "sin" | "cos" | "tan" | "asin" | "acos"
| "atan" | "sqrt" | "exp" | "abs" | "sign" => {
self.input.skip_ws();
let calc_sum = ComponentValue::CalcSum(self.parse()?);
values.push(calc_sum);
self.input.skip_ws();
if !is!(self, EOF) {
let span = self.input.cur_span();
return Err(Error::new(span, ErrorKind::Unexpected("value")));
}
}
"min" | "max" | "hypot" => {
self.input.skip_ws();
let calc_sum = ComponentValue::CalcSum(self.parse()?);
values.push(calc_sum);
loop {
self.input.skip_ws();
if is!(self, ",") {
values.push(ComponentValue::Delimiter(self.parse()?));
self.input.skip_ws();
} else {
break;View on GitHub (pinned to 5176682b65)
Solutions
- Pass exactly one math expression argument: 'calc(1px + 2%)'
- Use a comma-separated multi-argument function (e.g. clamp, min, max) if several arguments are needed
- Remove trailing tokens before the ')'
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/swc_css_parser/src/parser/values_and_units/mod.rs:213 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/98444b4d55599f54.
Report an issue: GitHub.