gleam-lang/gleam · error

Writing to string buffer failed

Error message

Writing to string buffer failed

What it means

Error "Writing to string buffer failed" thrown in gleam-lang/gleam.

Source

Thrown at pretty-arena/src/lib.rs:375

            }
            PrintableDocument::Join4(first, second, third, fourth) => {
                first.is_empty() && second.is_empty() && third.is_empty() && fourth.is_empty()
            }
            // Zero-width strings don't count towards line length, but they are
            // still printed and so are not empty. (Unless their string contents
            // is also empty)
            PrintableDocument::ZeroWidthString { string } => string.is_empty(),
            PrintableDocument::ZeroWidthStr { string } => string.is_empty(),
            PrintableDocument::CursorPositionObserver { .. } => true,
        }
    }

    /// Prints a document into a `String`, attempting to limit lines to `limit`
    /// characters in length.
    pub fn to_pretty_string(self, limit: isize) -> String {
        let mut buffer = String::new();
        self.pretty_print(limit, &mut buffer)
            .expect("Writing to string buffer failed");
        buffer
    }

    /// Prints a document into `writer`, attempting to limit lines to `limit`
    /// characters in length.
    pub fn pretty_print(self, limit: isize, writer: &mut impl std::fmt::Write) -> std::fmt::Result {
        let docs = im::vector![(0, Mode::Unbroken, self)];
        format(writer, limit, docs)?;
        Ok(())
    }
}

/// A pretty printable document. A tree structure, made up of text and other
/// elements which determine how it can be formatted.
///
/// The variants of this enum should probably not be constructed directly,
/// rather use the helper functions on the DocumentArena to construct them.
///

View on GitHub (pinned to 7e623aa83d)

When it happens

Trigger: Thrown at pretty-arena/src/lib.rs:375 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/3f006f0ddc1fccb9. Report an issue: GitHub.