FuelLabs/fuels-rs · error · syn::Error

expected name='value'

Error message

expected name='value'

What it means

Compile-time parsing error from fuels-macros' UniqueNameValues helper: attribute arguments must be a comma-separated list of name='value' pairs (syn::MetaNameValue). If the token stream cannot be parsed as such (positional argument, missing =, unquoted value, stray token), the underlying syn error is remapped to 'expected name='value'' with the offending span.

Source

Thrown at packages/fuels-macros/src/parse_utils/unique_name_values.rs:23

use proc_macro2::{Ident, Span, TokenStream};
use syn::{
    Error, Expr, Lit, LitStr, MetaNameValue, parse::Parser, punctuated::Punctuated,
    spanned::Spanned,
};

use crate::parse_utils::{ErrorsExt, validate_no_duplicates};

#[derive(Debug)]
pub struct UniqueNameValues {
    span: Span,
    name_values: HashMap<Ident, Lit>,
}

impl UniqueNameValues {
    pub fn new(tokens: TokenStream) -> syn::Result<Self> {
        let name_value_metas = Punctuated::<MetaNameValue, syn::token::Comma>::parse_terminated
            .parse2(tokens)
            .map_err(|e| Error::new(e.span(), "expected name='value'"))?;
        let span = name_value_metas.span();
        let name_values = Self::extract_name_values(name_value_metas.into_iter())?;

        let names = name_values.iter().map(|(name, _)| name).collect::<Vec<_>>();
        validate_no_duplicates(&names, |&&name| name.clone())?;

        Ok(Self {
            span,
            name_values: name_values.into_iter().collect(),
        })
    }

    pub fn try_get(&self, name: &str) -> Option<&Lit> {
        self.name_values.get(&ident(name))
    }

    pub fn validate_has_no_other_names(&self, allowed_names: &[&str]) -> syn::Result<()> {
        let expected_names = allowed_names

View on GitHub (pinned to d9a250a518)

Solutions

  1. Inspect the span rustc points at — it is the exact token where MetaNameValue parsing failed.
  2. Rewrite the argument list as comma-separated name="string literal" pairs, e.g. (name="counter", project="../counter").
  3. Remove positional or expression arguments; every argument needs a key, an =, and a quoted literal.
  4. Compare with a working example in the repo's tests/examples for the same macro.

Example fix

// before
setup_program_test!(
    Abigen(contract = "counter", abi = "../out/debug/counter-abi.json")
)
// after
Abigen(
    contracts = [(name = "counter", abi = "../out/debug/counter-abi.json")]
)
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Invoking a fuels attribute/macro whose inner argument list is parsed via UniqueNameValues::new (e.g. program-setup commands or program attributes) with malformed input: Project("counter") instead of project="counter", name=counter (bare ident, not a literal), a trailing comma artifact, or nested tokens that are not MetaNameValue pairs.

Common situations: Copying usage from an older SDK version with different attribute syntax; writing unquoted values out of habit from other ecosystems; the first underlying error being masked so the user sees only this generic message.

Related errors


AI-assisted analysis of FuelLabs/fuels-rs@d9a250a518 (2026-08-16). Data as JSON: /api/errors/6ea9a7cf75515f3c. Report an issue: GitHub.