{"record":{"id":"396be4b0fb6dfbc1","repo":"zed-industries/zed","slug":"valid-regex","errorCode":null,"errorMessage":"valid regex","messagePattern":"valid regex","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/language/src/modeline.rs","lineNumber":79,"sourceCode":"    }\n\n    Some(settings).filter(|s| s.has_settings())\n}\n\nfn parse_modelines(modelines: &[&str], settings: &mut ModelineSettings) {\n    for line in modelines {\n        parse_emacs_modeline(line, settings);\n        // if emacs is set, do not check for vim modelines\n        if settings.has_settings() {\n            return;\n        }\n    }\n\n    parse_vim_modelines(modelines, settings);\n}\n\nstatic EMACS_MODELINE_RE: LazyLock<Regex> =\n    LazyLock::new(|| Regex::new(r\"-\\*-\\s*(.+?)\\s*-\\*-\").expect(\"valid regex\"));\n\n/// Parse Emacs-style modelines\n/// Format: -*- mode: rust; tab-width: 4; indent-tabs-mode: nil; -*-\n/// See Emacs (set-auto-mode)\nfn parse_emacs_modeline(line: &str, settings: &mut ModelineSettings) {\n    let Some(captures) = EMACS_MODELINE_RE.captures(line) else {\n        return;\n    };\n    let Some(modeline_content) = captures.get(1).map(|m| m.as_str()) else {\n        return;\n    };\n    for part in modeline_content.split(';') {\n        parse_emacs_key_value(part, settings, true);\n    }\n}\n\n/// Parse Emacs-style Local Variables block\n///","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/language/src/modeline.rs#L61-L97","documentation":"LazyLock initializer for the Emacs modeline regex; the regex crate failed to compile the constant pattern `-\\*-\\s*(.+?)\\s*-\\*-`. Because the pattern is a compile-time constant written by developers, failure can only come from a regex crate version change altering syntax/limits — never from file content. The assert documents that the constant is known-valid.","triggerScenarios":"Thrown at crates/language/src/modeline.rs:79 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Run the regex in a unit test (Regex::new on the same literal) to surface the compile error and adjust syntax","Pin the regex crate version if a SemVer-incompatible change introduced new syntax rules","Simplify the pattern if it exceeds default size limits"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}