typst/typst · error

`{field}` is not a valid method for {kind} `{name}`

Error message

`{field}` is not a valid method for {kind} `{name}`

What it means

From eval_field_callee in the evaluator: code used method-call syntax (`target.field(...)`), but `field` resolved to a non-callable field value on the given target kind and name — the field exists as data, not as a method, so it cannot be invoked. The at-fault input is the field name applied to that target.

Source

Thrown at crates/typst-eval/src/call.rs:282

            .read(guard)
            .or_cannot(format_args!("call method `{field}` on content"))
            .at(field_span)?
            .clone()
    } else if matches!(target, Value::Symbol(_) | Value::Type(_) | Value::Module(_)) {
        // These types are allowed to use field call syntax on non-methods.
        target.field(field, guard).at(field_span)?
    } else if let Value::Func(func) = &target {
        // Functions can also use field call syntax on non-methods, but not for
        // settable fields accessed from context.
        match target.field(field, guard).at(field_span) {
            Ok(callee_value) => callee_value,
            Err(err) => {
                if let Some(element) = func.to_element()
                    && let Some(field_accessor) = element.settable_field_accessor(field)
                {
                    let styles = vm.context.styles().at(field_span)?;
                    let callee_value = field_accessor(styles);
                    bail!(disallowed_field_call_error(
                        callee_value,
                        access,
                        field,
                        target,
                        in_math
                    ));
                } else {
                    return Err(err);
                }
            }
        }
    } else {
        // Otherwise we are not allowed to call the field and produce an error.
        match target.field(field, guard) {
            // The field does exist.
            Ok(callee_value) => {
                bail!(disallowed_field_call_error(
                    callee_value,

View on GitHub (pinned to 35417aa769)

Solutions

  1. Access the field without calling it: `target.field` instead of `target.field(...)`
  2. Check the target's documentation for the correct method name
  3. Wrap the retrieved value if you meant to call a function stored in the field
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/typst-eval/src/call.rs:282 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/e0262a616b064ed5. Report an issue: GitHub.