typst/typst · error

unexpected argument: {name}

Error message

unexpected argument: {name}

What it means

Raised by Args::finish when leftover named arguments remain after a function or element consumed its expected parameters. Finish is the end-of-dispatch completeness check; a remaining named argument means the caller passed a parameter the callee never declared.

Source

Thrown at crates/typst-library/src/foundations/args.rs:263

            Some(value) => Ok(Some(value)),
            None => self.find(),
        }
    }

    /// Take out all arguments into a new instance.
    pub fn take(&mut self) -> Self {
        Self {
            span: self.span,
            items: std::mem::take(&mut self.items),
        }
    }

    /// Return an "unexpected argument" error if there is any remaining
    /// argument.
    pub fn finish(self) -> SourceResult<()> {
        if let Some(arg) = self.items.first() {
            match &arg.name {
                Some(name) => bail!(arg.span, "unexpected argument: {name}"),
                _ => bail!(arg.span, "unexpected argument"),
            }
        }
        Ok(())
    }
}

/// A key that can be used to get an argument: either the index of a positional
/// argument, or the name of a named argument.
#[derive(Debug, Clone, Eq, PartialEq)]
pub enum ArgumentKey {
    Index(i64),
    Name(Str),
}

cast! {
    ArgumentKey,
    v: i64 => Self::Index(v),

View on GitHub (pinned to 6a6f1a97a3)

Solutions

  1. Remove the unexpected named argument from the call
  2. Check the spelling of the parameter name against the function or element's signature
  3. Pass the value positionally if it was intended as a positional argument
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/typst-library/src/foundations/args.rs:262 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of typst/typst@6a6f1a97a3 (2026-08-17). Data as JSON: /api/errors/a5eef0c562687a87. Report an issue: GitHub.