{"record":{"id":"3b6983b656ac1d89","repo":"swc-project/swc","slug":"number-dimension-functions-math-functions-or-i","errorCode":null,"errorMessage":"number, dimension, functions (math functions) or ident (with 'none' value) token","messagePattern":"number, dimension, functions \\(math functions\\) or ident \\(with 'none' value\\) token","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/swc_css_parser/src/parser/values_and_units/mod.rs","lineNumber":1187,"sourceCode":"                                        Ok(Some(ComponentValue::Function(parser.parse()?)))\n                                    }\n                                    tok!(\"ident\") => {\n                                        let ident: Box<Ident> = parser.parse()?;\n\n                                        if ident.value.eq_ignore_ascii_case(\"none\") {\n                                            Ok(Some(ComponentValue::Ident(ident)))\n                                        } else {\n                                            Err(Error::new(\n                                                ident.span,\n                                                ErrorKind::Expected(\n                                                    \"'none' value of an ident token\",\n                                                ),\n                                            ))\n                                        }\n                                    }\n                                    _ => {\n                                        if !has_variable_before {\n                                            return Err(Error::new(\n                                                parser.input.cur_span(),\n                                                ErrorKind::Expected(\n                                                    \"number, dimension, functions (math \\\n                                                     functions) or ident (with 'none' value) token\",\n                                                ),\n                                            ));\n                                        } else {\n                                            Ok(None)\n                                        }\n                                    }\n                                },\n                                &mut has_variable,\n                            )?;\n\n                            if let Some(hue_or_none) = hue_or_none {\n                                values.push(hue_or_none);\n                            }\n","sourceCodeStart":1169,"sourceCodeEnd":1205,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_css_parser/src/parser/values_and_units/mod.rs#L1169-L1205","documentation":"Thrown by swc_css_parser when the hue (third) component of lch()/oklch() starts with a token that is not a number, dimension, math function, or ident. This catch-all arm is the only one in the group that uses `return Err(...)` (mod.rs:1186-1193); the span is the current token. Suppressed when a var() precedes it in the same color function.","triggerScenarios":"`oklch(70% 0.1 \"120\")` — hue given as a string; `lch(50% 10, 30)` — legacy comma reaching the hue slot; `lch(50% 10 #fff)`; `oklch(70% 0.1 rgb(0 0 0))` — a non-math function in the hue slot.","commonSituations":"Mechanical conversion from comma-separated syntax; string interpolation of hue values; nesting a color function where a hue is expected.","solutions":["Provide hue as number/angle or via a math function: oklch(70% 0.1 120) or oklch(70% 0.1 calc(120deg * 2)).","Remove commas: lch(50% 10 30).","Unquote interpolated numeric values.","Wrap dynamic hue in var()."],"exampleFix":"/* before */\ncolor: oklch(70% 0.1 \"120\");\n\n/* after */\ncolor: oklch(70% 0.1 120);","handlingStrategy":"try-catch","validationCode":"fn lch_hue_token_ok(tok: &str) -> bool {\n    let t = tok.trim();\n    t.eq_ignore_ascii_case(\"none\")\n        || t.parse::<f64>().is_ok()\n        || is_angle_or_number(t)\n        || is_math_fn(t)\n}","typeGuard":"fn hue_is_unquoted(t: &str) -> bool {\n    !t.trim().starts_with('\"') && !t.trim().starts_with('\\'')\n}","tryCatchPattern":"if let Err(e) = swc_css_parser::parse_file::<swc_css_ast::Stylesheet>(&fm, None, config, &mut errs) {\n    if let swc_css_parser::error::ErrorKind::Expected(m) = e.kind() {\n        if m.starts_with(\"number, dimension, functions\") {\n            // bad hue token in lch/oklch at e span; recover and report\n        }\n    }\n}","preventionTips":["Never quote hue values produced by templating.","Strip commas when converting legacy color syntax.","Reject nested non-math functions in the hue slot during lint.","Feed dynamic hue through var()."],"tags":["css","swc","parser","color","lch","oklch","hue","legacy-comma","syntax"],"backgroundTag":"css-unexpected-token","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}