vosen/ZLUDA · error

Unexpected key `{}`. Expected `type`, `data`, `arguments`, `

Error message

Unexpected key `{}`. Expected `type`, `data`, `arguments`, `visit, `visit_mut` or `map`.

What it means

This is a compile-time error from the `parse` function of a proc-macro DSL (`ptx_parser_macros`). When parsing a variant's attribute body, an unknown identifier key was found where only `type`, `data`, `arguments`, `visit`, `visit_mut`, or `map` are accepted. The `syn::Error` points at the offending key's span so rustc underlines it in the source. Note the message itself has a typo (missing closing backtick after `visit`).

Source

Thrown at ptx_parser_macros_impl/src/lib.rs:481

                }
                "visit" => {
                    input.parse::<Token![:]>()?;
                    VariantProperty::Visit(input.parse::<Expr>()?)
                }
                "visit_mut" => {
                    input.parse::<Token![:]>()?;
                    VariantProperty::VisitMut(input.parse::<Expr>()?)
                }
                "display" => {
                    input.parse::<Token![:]>()?;
                    VariantProperty::Display(input.parse::<Expr>()?)
                }
                "map" => {
                    input.parse::<Token![:]>()?;
                    VariantProperty::Map(input.parse::<Expr>()?)
                }
                x => {
                    return Err(syn::Error::new(
                        key.span(),
                        format!(
                            "Unexpected key `{}`. Expected `type`, `data`, `arguments`, `visit, `visit_mut` or `map`.",
                            x
                        ),
                    ))
                }
            }
        } else {
            return Err(lookahead.error());
        })
    }
}

pub enum Arguments {
    Decl(Type),
    Def(InstructionArguments),
}

View on GitHub (pinned to 9c8b43f242)

Solutions

  1. Rename the key to one of the supported ones: `type`, `data`, `arguments`, `visit`, `visit_mut`, `map`
  2. Fix casing — keys are matched exactly (`visit_mut`, not `VisitMut` or `Visit`)
  3. Check the macro's documentation or the match arms in ptx_parser_macros_impl/src/lib.rs:434-489 for the current key set; if a needed key is missing, upstream the change
  4. If you intended a key like `display`, note it is accepted elsewhere but not in this position — verify you are on the right attribute

Example fix

// before
MyVariant { foo: expr() } => ...
// after
MyVariant { map: expr() } => ...
Defensive patterns

Strategy: type-guard

Type guard

// Compile-time guard: the proc macro rejects unknown keys at compile time,
// so the only defense is sticking to the accepted key set:
// type | data | arguments | visit | visit_mut | map
const VALID_KEYS: &[&str] = &["type", "data", "arguments", "visit", "visit_mut", "map"];

Prevention

When it happens

Trigger: Writing an attribute like `#[variant(display_name: "...")]`, `kind: ...`, or a misspelled key (`types:`, `argumnts:`, `Visits:`) inside a variant body handled by `VariantProperty::parse`. Case-sensitivity matters, so `Map:` or `MAP` also fail.

Common situations: Typos in macro attribute keys, copying DSL syntax from an older/newer version of the macro where the key set differed, or inventing keys assuming the DSL accepts arbitrary properties.

Understand the failure class

Background: "invalid argument", "unknown mode", "not supported": invalid enum-like argument errors explained — this error's family across 19 libraries.

Related errors


AI-assisted analysis of vosen/ZLUDA@9c8b43f242 (2026-09-06). Data as JSON: /api/errors/839d535e5ee68039. Report an issue: GitHub.