{"record":{"id":"a3e5149eb65c2eb1","repo":"slint-ui/slint","slug":"parsing-failed","errorCode":null,"errorMessage":"Parsing failed.","messagePattern":"Parsing failed\\.","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"tools/lsp/fmt/tool.rs","lineNumber":112,"sourceCode":"        source_slice = &source_slice[code_end..];\n\n        had_error |= process_slint_code(code, &mut file, None)?;\n    }\n    file.write_all(source_slice.as_bytes())?;\n    check_error(had_error)\n}\n\nfn process_slint_file(\n    source: String,\n    path: &std::path::Path,\n    mut file: impl Write,\n) -> std::io::Result<()> {\n    check_error(process_slint_code(source.as_str(), &mut file, Some(path))?)\n}\n\nfn check_error(error: bool) -> std::io::Result<()> {\n    if error {\n        Err(std::io::Error::new(std::io::ErrorKind::InvalidData, \"Parsing failed.\"))\n    } else {\n        Ok(())\n    }\n}\n\nfn process_file(\n    source: String,\n    path: &std::path::Path,\n    mut file: impl Write,\n) -> std::io::Result<()> {\n    let result = match path.extension() {\n        Some(ext) if ext == \"rs\" => process_rust_file(source, file),\n        Some(ext) if ext == \"md\" => process_markdown_file(source, file),\n        Some(ext) if ext == \"slint\" => process_slint_file(source, path, file),\n        _ => {\n            // This allows usage like `cat x.slint | slint-lsp format /dev/stdin`\n            if path == Path::new(\"/dev/stdin\") {\n                return process_slint_file(source, path, file);","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/tools/lsp/fmt/tool.rs#L94-L130","documentation":"`check_error` converts the boolean parse-failure result of the slint formatter into an `io::Error::InvalidData`. When the Slint (or embedded Rust/Markdown code block) source cannot be parsed, formatting cannot proceed, so the tool fails with \"Parsing failed.\".","triggerScenarios":"`process_slint_code` returns `true` (parse error) — i.e. the source passed to the formatter contains a syntax error. Called from `process_rust_file`, `process_markdown_file`, or `process_slint_file` when formatting a file with invalid syntax.","commonSituations":"Running slint-fmt on a hand-edited .slint file with a typo; formatting a markdown file whose slint code block is intentionally invalid/partial; version mismatch where newer syntax is formatted by an older slint-fmt.","solutions":["Run `slint-viewer` or the LSP on the file to find and fix the syntax error reported by the compiler","Check for newer Slint language syntax that this slint-fmt version doesn't support; update the tool","If in a markdown file, ensure the fenced code block content is complete valid Slint (no prose/placeholder fragments)"],"exampleFix":"// before: file with syntax error\nexport component A { property<int x; }\n// after: fixed syntax\nexport component A { property<int> x; }","handlingStrategy":"try-catch","validationCode":"let mut diag = Default::default();\nlet compiled = slint_interpreter::compile(source.as_str(), &path.to_string_lossy(), None, &mut diag);\nif !diag.is_empty() { eprintln!(\"{}\", diag); std::process::exit(1); }","typeGuard":null,"tryCatchPattern":"if let Err(e) = process_slint_file(&path) {\n    if e.kind() == std::io::ErrorKind::InvalidData {\n        eprintln!(\"{}: Slint syntax error — run the compiler/LSP to see diagnostics: {e}\", path.display());\n        std::process::exit(1);\n    }\n    return Err(e);\n}","preventionTips":["Run slint-fmt only on sources that already pass the Slint compiler (e.g. after CI linting)","Pin slint-fmt to the same version as the Slint language your project uses","For markdown files, validate each fenced slint block individually and skip intentionally incomplete snippets"],"tags":["formatting","parsing","slint","cli"],"backgroundTag":"schema-validation-failed","analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}