{"record":{"id":"8b717858e30003d1","repo":"slint-ui/slint","slug":"could-not-compile-path","errorCode":null,"errorMessage":"Could not compile {path}","messagePattern":"Could not compile (.+?)","errorType":"exception","errorClass":"CompileError","httpStatus":null,"severity":"error","filePath":"api/python/slint/slint/__init__.py","lineNumber":349,"sourceCode":"    if translation_domain is not None:\n        compiler.translation_domain = translation_domain\n\n    result = compiler.build_from_path(Path(path))\n\n    diagnostics = result.diagnostics\n    if diagnostics:\n        if not quiet:\n            for diag in diagnostics:\n                if diag.level == native.DiagnosticLevel.Warning:\n                    _logger.warning(diag)\n                if diag.level == native.DiagnosticLevel.Note:\n                    _logger.debug(diag)\n\n        errors = [\n            diag for diag in diagnostics if diag.level == native.DiagnosticLevel.Error\n        ]\n        if errors:\n            raise CompileError(f\"Could not compile {path}\", diagnostics)\n\n    module = types.SimpleNamespace()\n    for comp_name in result.component_names:\n        wrapper_class = _build_class(result.component(comp_name))\n\n        setattr(module, comp_name, wrapper_class)\n\n    structs, enums = result.structs_and_enums\n\n    for name, struct_prototype in structs.items():\n        name = _normalize_prop(name)\n        struct_wrapper = _build_struct(name, struct_prototype)\n        setattr(module, name, struct_wrapper)\n\n    for name, enum_class in enums.items():\n        name = _normalize_prop(name)\n        setattr(module, name, enum_class)\n","sourceCodeStart":331,"sourceCodeEnd":367,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/api/python/slint/slint/__init__.py#L331-L367","documentation":"Raised by _load_file when the Slint compiler produced error-level diagnostics while compiling the given .slint file. The CompileError carries the full diagnostics list, so the actual parse/type errors are available on the exception.","triggerScenarios":"Calling slint.load_file(path) (directly or via load/compile APIs) on a .slint file containing syntax errors, unknown elements/properties, type errors, or missing imports.","commonSituations":"Typos in .slint markup; using features not enabled in the compiler version; referencing components or globals that don't exist; broken paths in imports; editing .slint files by hand without an LSP.","solutions":["Catch slint.CompileError and inspect e.diagnostics to see each error's line/column and message.","Fix the reported .slint errors (syntax, unknown identifiers, type errors) in the referenced file.","Check import paths and that all referenced components/globals exist and are exported.","Validate the file with the slint-viewer or an editor with the Slint LSP before loading it at runtime."],"exampleFix":"# before\nmodule = slint.load_file(\"app.slint\")  # raises CompileError\n\n# after\ntry:\n    module = slint.load_file(\"app.slint\")\nexcept slint.CompileError as e:\n    for d in e.diagnostics:\n        print(d.filename, d.line, d.column, d.message)","handlingStrategy":"try-catch","validationCode":"from pathlib import Path\nassert Path(\"app.slint\").exists(), \"missing .slint file\"","typeGuard":null,"tryCatchPattern":"try:\n    module = slint.load_file(\"app.slint\")\nexcept slint.CompileError as e:\n    for d in e.diagnostics:\n        print(f\"{d.filename}:{d.line}:{d.column}: {d.message}\")\n    raise","preventionTips":["Run the Slint compiler/viewer or LSP diagnostics on .slint files in CI before runtime.","Never hand-edit .slint without checking diagnostics; inspect e.diagnostics for line numbers."],"tags":["python","compilation","slint","syntax-error"],"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"}