{"record":{"id":"78df13106766cc90","repo":"gleam-lang/gleam","slug":"pattern-variable-used-before-assignment","errorCode":null,"errorMessage":"pattern variable used before assignment","messagePattern":"pattern variable used before assignment","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-core/src/javascript/decision.rs","lineNumber":2336,"sourceCode":"        check_assignments\n    }\n\n    /// Returns a string representing the value of a pattern variable: it might\n    /// be the code needed to obtain such variable (for example accessing a\n    /// list item `wibble.head`), or it could be a name this variable was bound\n    /// to in the current scope to avoid doing any repeated work!\n    ///\n    fn get_value(&self, variable: &Variable) -> EcoString {\n        // If the pattern variable was already assigned to a variable that is\n        // in scope we use that variable name!\n        if let Some(name) = self.scoped_variable_names.get(&variable.id) {\n            return name.clone();\n        }\n\n        // Otherwise we fallback to using its value directly.\n        self.variable_values\n            .get(&variable.id)\n            .expect(\"pattern variable used before assignment\")\n            .clone()\n    }\n\n    fn get_segment_value(\n        &self,\n        arena: &'doc DocumentArena<'a, 'doc>,\n        segment_name: &EcoString,\n    ) -> Option<Document<'a, 'doc>> {\n        // If the segment was already assigned to a variable that is in scope\n        // we use that variable name!\n        if let Some(name) = self.scoped_segment_names.get(segment_name) {\n            return Some(name.clone().to_doc(arena));\n        }\n\n        // Otherwise we fallback to using its value directly.\n        self.segment_values.get(segment_name).cloned()\n    }\n}","sourceCodeStart":2318,"sourceCodeEnd":2354,"githubUrl":"https://github.com/gleam-lang/gleam/blob/7e623aa83da3776faee50ca4ab9a6c40124acd95/compiler-core/src/javascript/decision.rs#L2318-L2354","documentation":"Error \"pattern variable used before assignment\" thrown in gleam-lang/gleam.","triggerScenarios":"Thrown at compiler-core/src/javascript/decision.rs:2336 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"}