gleam-lang/gleam · error

invalid clause index

Error message

invalid clause index

What it means

Error "invalid clause index" thrown in gleam-lang/gleam.

Source

Thrown at compiler-core/src/javascript/decision.rs:352

                    subject,
                } = &self.kind
                {
                    CaseBody::Statements(self.assignment_no_match(
                        arena,
                        subject.to_doc(arena),
                        kind,
                        *subject_location,
                        *pattern_location,
                    ))
                } else {
                    unreachable!("Invalid decision tree reached code generation")
                }
            }
            Decision::Run { body } => {
                let location = match self.kind {
                    DecisionKind::Case { clauses } => clauses
                        .get(body.clause_index)
                        .expect("invalid clause index")
                        .location(),
                    DecisionKind::LetAssert {
                        subject_location,
                        pattern_location,
                        ..
                    } => match self.variables.variable_assignment {
                        // When the variables are being declared, they
                        // correspond to the pattern.
                        VariableAssignment::Declare => pattern_location,
                        // When the variables are being assigned, they
                        // correspond to the subject.
                        VariableAssignment::Reassign => subject_location,
                    },
                };
                let source_map_tracker = self
                    .variables
                    .expression_generator
                    .source_map_tracker(arena, location.start);

View on GitHub (pinned to 7e623aa83d)

When it happens

Trigger: Thrown at compiler-core/src/javascript/decision.rs:352 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/7e6916c5860f9bb9. Report an issue: GitHub.