{"record":{"id":"7c74f194226c690f","repo":"swc-project/swc","slug":"expected-ident","errorCode":null,"errorMessage":"Expected ident","messagePattern":"Expected ident","errorType":"validation","errorClass":"swc_css_parser::error::Error","httpStatus":null,"severity":"error","filePath":"crates/swc_css_parser/src/parser/at_rules/mod.rs","lineNumber":2117,"sourceCode":"        })\n    }\n}\n\nimpl<I> Parse<ContainerName> for Parser<I>\nwhere\n    I: ParserInput,\n{\n    fn parse(&mut self) -> PResult<ContainerName> {\n        match cur!(self) {\n            tok!(\"ident\") => {\n                let custom_ident: CustomIdent = self.parse()?;\n\n                Ok(ContainerName::CustomIdent(custom_ident))\n            }\n            _ => {\n                let span = self.input.cur_span();\n\n                Err(Error::new(span, ErrorKind::Expected(\"ident\")))\n            }\n        }\n    }\n}\n\nimpl<I> Parse<ContainerQuery> for Parser<I>\nwhere\n    I: ParserInput,\n{\n    fn parse(&mut self) -> PResult<ContainerQuery> {\n        let start_pos = self.input.cur_span().lo;\n        let mut last_pos;\n\n        let mut queries = Vec::new();\n\n        if is_case_insensitive_ident!(self, \"not\") {\n            let not = self.parse()?;\n","sourceCodeStart":2099,"sourceCodeEnd":2135,"githubUrl":"https://github.com/swc-project/swc/blob/5176682b65416c6b5de6b47379ae1588ea3ecb3f/crates/swc_css_parser/src/parser/at_rules/mod.rs#L2099-L2135","documentation":"Thrown while parsing a <container-name> — the name slot of @container preludes (and the container-name property path). The token must be a <custom-ident>; anything else (number, string, hash, dimension, or EOF) raises ErrorKind::Expected(\"ident\") at the current token span. CSS-wide keywords are additionally rejected later by the CustomIdent rules with a dedicated error.","triggerScenarios":"'@container 20px (width > 40em)' (dimension as name), '@container \"card\" (width > 40em)' (string), '@container #main (...)' (hash token).","commonSituations":"Authors mixing up container-name and container-type values in the shorthand, generated queries where the name variable is empty or numeric, and confusion with the named-page syntax.","solutions":["Give the container an identifier name: @container card (width > 40em) { }","Omit the name for the unnamed query: @container (width > 40em) { }","Set names via the container-name property with a <custom-ident>; avoid css-wide keywords like none/default"],"exampleFix":"/* before */\n@container \"card\" (width > 40em) { }\n\n/* after */\n@container card (width > 40em) { }","handlingStrategy":"validation","validationCode":"fn container_name_ok(name: &str) -> bool {\n    let mut chars = name.chars();\n    match chars.next() {\n        Some(c) if c.is_ascii_alphabetic() || c == '_' || c == '-' => {}\n        _ => return false,\n    }\n    name.chars().all(|c| c.is_ascii_alphanumeric() || c == '_' || c == '-')\n        && ![\"none\", \"initial\", \"inherit\", \"unset\", \"revert\"].iter().any(|k| name.eq_ignore_ascii_case(k))\n}","typeGuard":"fn is_container_name_error(e: &swc_css_parser::error::Error) -> bool {\n    matches!(e.kind(), swc_css_parser::error::ErrorKind::Expected(m) if *m == \"ident\")\n}","tryCatchPattern":"match parse_file::<Stylesheet>(&fm, None, config, &mut errors) {\n    Ok(sheet) => handle(sheet),\n    Err(err) if is_container_name_error(&err) => {\n        let (span, _) = *err.into_inner();\n        hint_at_span(css, span, \"@container expects an <custom-ident> name (or none at all): @container card (width > 40em)\");\n    }\n    Err(err) => return Err(err.into()),\n}","preventionTips":["Keep container names as identifiers in your data model, not free strings","Skip the name slot entirely for unnamed containers","Avoid css-wide keywords as names","Assert name shape before interpolating into @container templates"],"tags":["css","swc","parser","at-rules","container-query","syntax"],"backgroundTag":"css-container-query-syntax","analyzedSha":"5176682b65416c6b5de6b47379ae1588ea3ecb3f","analyzedAt":"2026-08-17T16:16:52.067Z","contentChangedAt":"2026-08-17T16:16:52.067Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}