{"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/a9ea814a5813e7460fa1a867924872095a4d678d/api/python/slint/slint/__init__.py#L331-L367","documentation":"slint.load_file()/load_str() compile .slint through the native interpreter and collect diagnostics; warnings are logged (unless quiet=True) and any diagnostic of level Error causes slint.CompileError to be raised with message 'Could not compile <path>'. Each PyDiagnostic in error.diagnostics (also attached as exception notes) carries file, line, column and message pinpointing the failure.","triggerScenarios":"Calling slint.load_file(\"app.slint\") (or load_str) on markup with syntax errors, unknown elements/properties, type mismatches, or unresolvable imports; also when an imported file is missing from the include paths.","commonSituations":"Typos in .slint, renamed APIs after a slint-python upgrade, wrong relative import paths, styles not installed, or loading a file written for a newer Slint version.","solutions":["Catch slint.CompileError and print each diagnostic (its str() includes file:line:column and message) to find the exact markup problem.","Fix the reported locations in the .slint source.","Ensure imports resolve: run from the right working directory or adjust include paths.","Validate markup beforehand with the Slint LSP / VS Code extension or slint-viewer.","Reinstall/upgrade the slint Python package to match the markup's feature level."],"exampleFix":"# before\nimport slint\nmodule = slint.load_file(\"app.slint\")  # raises CompileError\n\n# after\nimport slint\ntry:\n    module = slint.load_file(\"app.slint\")\nexcept slint.CompileError as e:\n    for diag in e.diagnostics:\n        print(diag)  # [file:line:col] message\n    raise SystemExit(1)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"def is_compile_error(e: BaseException) -> bool:\n    return isinstance(e, slint.CompileError)","tryCatchPattern":"try:\n    module = slint.load_file(\"app.slint\")\nexcept slint.CompileError as e:\n    for diag in e.diagnostics:\n        print(diag)  # [file:line:col] message\n    raise SystemExit(1)","preventionTips":["Validate .slint in CI with the Slint LSP or slint-viewer before Python loads it.","Load files from stable absolute paths or set include paths so imports resolve.","Upgrade the slint package and .slint markup together."],"tags":["python","slint","compiler","diagnostics","markup"],"backgroundTag":"compile-error-diagnostics","analyzedSha":"a9ea814a5813e7460fa1a867924872095a4d678d","analyzedAt":"2026-08-16T22:39:12.830Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}