gleam-lang/gleam · error

echo with no previous step in a pipe

Error message

echo with no previous step in a pipe

What it means

Error "echo with no previous step in a pipe" thrown in gleam-lang/gleam.

Source

Thrown at compiler-core/src/javascript/expression.rs:1046

        let all_assignments = std::iter::once(first_value)
            .chain(assignments.iter().map(|(assignment, _kind)| assignment));

        let mut latest_local_var: Option<EcoString> = None;
        for assignment in all_assignments {
            // An echo in a pipeline won't result in an assignment, instead it
            // just prints the previous variable assigned in the pipeline.
            if let TypedExpr::Echo {
                expression: None,
                message,
                location,
                ..
            } = assignment.value.as_ref()
            {
                documents.push(self.not_in_tail_position(Some(Ordering::Strict), |this| {
                    let var = latest_local_var
                        .as_ref()
                        .expect("echo with no previous step in a pipe");
                    this.echo(arena, var.to_doc(arena), message.as_deref(), location)
                }));
                documents.push(SEMICOLON_DOCUMENT);
            } else {
                // Otherwise we assign the intermediate pipe value to a variable.
                let assignment_document =
                    self.not_in_tail_position(Some(Ordering::Strict), |this| {
                        this.simple_variable_assignment(
                            arena,
                            &assignment.name,
                            &assignment.value,
                            assignment.location,
                        )
                    });
                documents.push(self.add_statement_level(arena, assignment_document));
                latest_local_var = Some(self.local_var(&assignment.name));
            }

View on GitHub (pinned to 7e623aa83d)

When it happens

Trigger: Thrown at compiler-core/src/javascript/expression.rs:1046 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/8389a7974a2daf20. Report an issue: GitHub.