gleam-lang/gleam · error
pattern variable used before assignment
Error message
pattern variable used before assignment
What it means
Error "pattern variable used before assignment" thrown in gleam-lang/gleam.
Source
Thrown at compiler-core/src/javascript/decision.rs:2336
check_assignments
}
/// Returns a string representing the value of a pattern variable: it might
/// be the code needed to obtain such variable (for example accessing a
/// list item `wibble.head`), or it could be a name this variable was bound
/// to in the current scope to avoid doing any repeated work!
///
fn get_value(&self, variable: &Variable) -> EcoString {
// If the pattern variable was already assigned to a variable that is
// in scope we use that variable name!
if let Some(name) = self.scoped_variable_names.get(&variable.id) {
return name.clone();
}
// Otherwise we fallback to using its value directly.
self.variable_values
.get(&variable.id)
.expect("pattern variable used before assignment")
.clone()
}
fn get_segment_value(
&self,
arena: &'doc DocumentArena<'a, 'doc>,
segment_name: &EcoString,
) -> Option<Document<'a, 'doc>> {
// If the segment was already assigned to a variable that is in scope
// we use that variable name!
if let Some(name) = self.scoped_segment_names.get(segment_name) {
return Some(name.clone().to_doc(arena));
}
// Otherwise we fallback to using its value directly.
self.segment_values.get(segment_name).cloned()
}
}View on GitHub (pinned to 7e623aa83d)
When it happens
Trigger: Thrown at compiler-core/src/javascript/decision.rs:2336 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of gleam-lang/gleam@7e623aa83d (2026-08-17).
Data as JSON: /api/errors/78df13106766cc90.
Report an issue: GitHub.