{"record":{"id":"f4cd0107779c728c","repo":"slint-ui/slint","slug":"libglobal-not-found","errorCode":null,"errorMessage":"LibGlobal not found","messagePattern":"LibGlobal not found","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/compiler/passes/collect_globals.rs","lineNumber":119,"sourceCode":"export component App {\n    out property <string> text-out: \"\\{LibGlobal.value} \\{LibGlobal.count} \\{LibGlobal.ready}\";\n}\n\"#\n            .into(),\n            Some(std::path::Path::new(\"test.slint\")),\n            &mut diag,\n        );\n        let (mut doc, diag, _) =\n            spin_on::spin_on(crate::compile_syntax_node(doc_node, diag, compiler_config));\n        assert!(!diag.has_errors(), \"compile error: {:?}\", diag.to_string_vec());\n\n        let global = doc\n            .used_types\n            .borrow()\n            .globals\n            .iter()\n            .find(|g| g.id == \"LibGlobal\")\n            .expect(\"LibGlobal not found\")\n            .clone();\n\n        // Simulate a library import by adding `LibGlobal` to `library_exports`\n        // and re-running `mark_library_globals`. Clear `expose_in_public_api`\n        // so the `is_constant_impl` short-circuit doesn't mask the result.\n        doc.library_exports.insert(\n            \"LibGlobal\".to_string(),\n            crate::typeloader::LibraryInfo {\n                name: \"Lib\".into(),\n                package: \"lib\".into(),\n                module: None,\n                exports: Vec::new(),\n            },\n        );\n        for (_, d) in global.root_element.borrow_mut().property_declarations.iter_mut() {\n            d.expose_in_public_api = false;\n        }\n        global.root_element.borrow().property_analysis.borrow_mut().clear();","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/internal/compiler/passes/collect_globals.rs#L101-L137","documentation":"This `expect` lives in `mark_library_globals_marks_properties_as_externally_used` (internal/compiler/passes/collect_globals.rs:119), a test helper that searches the document's used globals for the compiler-internal `LibGlobal` global and asserts it is present. `LibGlobal` is a synthetic global the compiler injects; if it is missing from `used_types.globals` at this point, the compiler's global-collection invariant is broken.","triggerScenarios":"Running this collect_globals test path (or code sharing its assumption) after `mark_used_globals`/`mark_library_globals` when `LibGlobal` was never collected — e.g. `is_constant_impl` short-circuiting marked properties, global marking skipped for the document, or a contributor change that removed/renamed `LibGlobal` injection.","commonSituations":"Slint compiler development and CI; changes to global marking or constant evaluation that alter which globals land in `used_types`; test setups that bypass normal document compilation.","solutions":["Ensure `mark_used_globals` (or the equivalent pass) ran on the document before this lookup so `LibGlobal` is registered as used.","Keep the `expose_in_public_api`/`is_constant_impl` conditions as the test intends so the marking short-circuit doesn't skip `LibGlobal`.","Verify the `LibGlobal` id string and injection code in the compiler were not renamed or removed.","Run `cargo test -p i-slint-compiler collect_globals` to confirm the fix."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Contributors: assert the precondition in tests\nassert!(doc.used_types.borrow().globals.iter().any(|g| g.id == \"LibGlobal\"),\n    \"run mark_used_globals before mark_library_globals\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always run the global-marking pass before code that reads used_types.globals.","Don't rename or conditionally skip LibGlobal injection.","Run the collect_globals unit tests after touching global marking code."],"tags":["rust","compiler","internal-panic","globals","test"],"backgroundTag":"internal-invariant-violation","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"}