gleam-lang/gleam · error

A module's function must be named

Error message

A module's function must be named

What it means

Error "A module's function must be named" thrown in gleam-lang/gleam.

Source

Thrown at compiler-core/src/javascript.rs:1180

        }

        // If there's an external JavaScript implementation then it will be imported,
        // so we don't need to generate a function definition.
        if function.external_javascript.is_some() {
            return None;
        }

        // If the function does not support JavaScript then we don't need to generate
        // a function definition.
        if !function.implementations.supports(Target::JavaScript) {
            return None;
        }
        let function_source_mapping = self.source_map_tracker(arena, function.location.start);

        let (_, name) = function
            .name
            .as_ref()
            .expect("A module's function must be named");
        let argument_names = function
            .arguments
            .iter()
            .map(|arg| arg.names.get_variable_name())
            .collect();

        let function_doc = match &function.documentation {
            None => EMPTY_DOCUMENT,
            Some((start, documentation)) => {
                docvec![
                    arena,
                    // 3 is the length of the "///" documentation marker.
                    // Start is the index of the actual content, so we need to subtract
                    // the length of the marker.
                    self.source_map_tracker(arena, *start - 3),
                    jsdoc_comment(arena, documentation, function.publicity),
                    LINE_DOCUMENT
                ]

View on GitHub (pinned to 7e623aa83d)

When it happens

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