typst/typst · error · EcoString

expected 2 delimiters, found {}

Error message

expected 2 delimiters, found {}

What it means

Raised while casting an array to DelimiterPair: the array must contain exactly two delimiters (open and close); a different number was found.

Source

Thrown at crates/typst-library/src/math/matrix.rs:345

/// A pair of delimiters (one closing, one opening) used for matrices, vectors
/// and cases.
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
pub struct DelimiterPair {
    open: Delimiter,
    close: Delimiter,
}

cast! {
    DelimiterPair,

    self => array![self.open, self.close].into_value(),

    v: Array => match v.as_slice() {
        [open, close] => Self {
            open: open.clone().cast()?,
            close: close.clone().cast()?,
        },
        _ => bail!("expected 2 delimiters, found {}", v.len())
    },
    v: Delimiter => Self { open: v, close: v.find_matching() }
}

impl DelimiterPair {
    const PAREN: Self = Self {
        open: Delimiter(Some('(')),
        close: Delimiter(Some(')')),
    };
    const BRACE: Self = Self {
        open: Delimiter(Some('{')),
        close: Delimiter(Some('}')),
    };

    /// The delimiter's opening character.
    pub fn open(self) -> Option<char> {
        self.open.get()
    }

View on GitHub (pinned to 35417aa769)

Solutions

  1. Provide exactly two delimiters, e.g. `(`, `]`
  2. Pass a single delimiter value to use it (or its match) on both sides
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/typst-library/src/math/matrix.rs:345 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of typst/typst@35417aa769 (2026-08-17). Data as JSON: /api/errors/3c43554729d08931. Report an issue: GitHub.