{"record":{"id":"7b16e69afb0ffdd6","repo":"gleam-lang/gleam","slug":"failed-to-take-ownership-of-sourcemap-builder","errorCode":null,"errorMessage":"Failed to take ownership of sourcemap builder","messagePattern":"Failed to take ownership of sourcemap builder","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-core/src/javascript.rs","lineNumber":1360,"sourceCode":"    pub stdlib_package: StdlibPackage,\n    pub path: &'a Utf8Path,\n    pub project_root: &'a Utf8Path,\n}\n\npub fn module(config: ModuleConfig<'_>) -> (String, Option<SourceMap>) {\n    let (output, sourcemap_builder) = {\n        let arena = DocumentArena::new();\n        let mut generator = Generator::new(config);\n        let document = generator.compile(&arena).to_pretty_string(80);\n        let builder = generator.source_map_builder;\n        (document, builder)\n    };\n\n    let source_map = sourcemap_builder.map(|builder| {\n        // We have completed the generation of the module, so we can now take ownership\n        // of the builder.\n        Rc::try_unwrap(builder)\n            .expect(\"Failed to take ownership of sourcemap builder\")\n            .into_inner()\n            .0\n            .into_sourcemap()\n    });\n    (output, source_map)\n}\n\npub fn ts_declaration(module: &TypedModule) -> String {\n    let arena = DocumentArena::new();\n    let document = typescript::TypeScriptGenerator::new(module).compile(&arena);\n    document.to_pretty_string(80)\n}\n\nfn create_cursor_position_observer<'a, 'doc>(\n    arena: &'doc DocumentArena<'a, 'doc>,\n    builder: &Option<Rc<RefCell<DebugIgnore<sourcemap::SourceMapBuilder>>>>,\n    line_numbers: &LineNumbers,\n    start_index: u32,","sourceCodeStart":1342,"sourceCodeEnd":1378,"githubUrl":"https://github.com/gleam-lang/gleam/blob/7e623aa83da3776faee50ca4ab9a6c40124acd95/compiler-core/src/javascript.rs#L1342-L1378","documentation":"Error \"Failed to take ownership of sourcemap builder\" thrown in gleam-lang/gleam.","triggerScenarios":"Thrown at compiler-core/src/javascript.rs:1360 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7e623aa83da3776faee50ca4ab9a6c40124acd95","analyzedAt":"2026-08-17T00:07:02.091Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}