{"record":{"id":"2c393e85a126dc0a","repo":"gleam-lang/gleam","slug":"missing-guard","errorCode":null,"errorMessage":"missing guard","messagePattern":"missing guard","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler-core/src/javascript/decision.rs","lineNumber":902,"sourceCode":"    }\n\n    fn decision_guard(\n        &mut self,\n        arena: &'doc DocumentArena<'a, 'doc>,\n        guard: usize,\n        if_true: &'a Body,\n        if_false: &'a Decision,\n    ) -> CaseBody<'a, 'doc> {\n        let DecisionKind::Case { clauses } = &self.kind else {\n            unreachable!(\"Guards cannot appear in let assert decision trees\")\n        };\n\n        let guard = clauses\n            .get(guard)\n            .expect(\"invalid clause index\")\n            .guard\n            .as_ref()\n            .expect(\"missing guard\");\n\n        // Before generating the if-else condition we want to generate all the\n        // assignments that will be needed by the guard condition so we can rest\n        // assured they are in scope and the guard check can use those.\n        let guard_variables = guard.referenced_variables();\n        let (check_bindings, if_true_bindings): (Vec<_>, Vec<_>) = if_true\n            .bindings\n            .iter()\n            .partition(|(variable, _)| guard_variables.contains(variable));\n\n        let (check_bindings, check, if_true) = self.inside_new_scope(|this| {\n            // check_bindings and if_true generation have to be in this scope so that pattern-bound\n            // variables used in guards don't leak into other case branches (if_false).\n            let check_bindings = this.variables.bindings_ref_doc(arena, &check_bindings);\n            let check = this.variables.expression_generator.guard(arena, guard);\n            // All the other bindings that are not needed by the guard check will\n            // end up directly in the body of the if clause.\n            let if_true_bindings = this.variables.bindings_ref_doc(arena, &if_true_bindings);","sourceCodeStart":884,"sourceCodeEnd":920,"githubUrl":"https://github.com/gleam-lang/gleam/blob/7e623aa83da3776faee50ca4ab9a6c40124acd95/compiler-core/src/javascript/decision.rs#L884-L920","documentation":"Error \"missing guard\" thrown in gleam-lang/gleam.","triggerScenarios":"Thrown at compiler-core/src/javascript/decision.rs:902 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"}