gleam-lang/gleam · error

case with no subjects

Error message

case with no subjects

What it means

Error "case with no subjects" thrown in gleam-lang/gleam.

Source

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

        &mut self,
        arena: &'doc DocumentArena<'a, 'doc>,
        clause_index: usize,
    ) -> BodyExpression<'a, 'doc> {
        // If we are not in a `case` expression, there is no additional code to
        // execute when a branch matches; we only assign variables bound in the
        // pattern.
        let DecisionKind::Case { clauses } = &self.kind else {
            return BodyExpression::Expressions(EMPTY_DOCUMENT);
        };

        let clause = &clauses.get(clause_index).expect("invalid clause index");
        let body = &clause.then;

        if let Some(subject_index) = clause.returned_subject() {
            let variable = self
                .assignments
                .get(subject_index)
                .expect("case with no subjects")
                .name();

            BodyExpression::Variable(
                self.variables
                    .expression_generator
                    .wrap_return(arena, variable.to_doc(arena)),
            )
        } else {
            BodyExpression::Expressions(
                self.variables
                    .expression_generator
                    .expression_flattening_blocks(arena, body),
            )
        }
    }

    fn switch(
        &mut self,

View on GitHub (pinned to 7e623aa83d)

When it happens

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