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_namesView on GitHub (pinned to d9a250a518)
Solutions
- Inspect the span rustc points at — it is the exact token where MetaNameValue parsing failed.
- Rewrite the argument list as comma-separated name="string literal" pairs, e.g. (name="counter", project="../counter").
- Remove positional or expression arguments; every argument needs a key, an =, and a quoted literal.
- 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
- Always write attribute args as name="value" string-literal pairs separated by commas.
- Copy argument syntax from the repo's own tests/examples rather than from memory.
- Fix the first macro error first — later spans often cascade from the first malformed token.
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
- must have exactly one element
- missing attribute '{name}'
- Unrecognized command. Expected one of: {msg}
- Only one `Abigen` command allowed
- Add an `Abigen(..)` command!
AI-assisted analysis of FuelLabs/fuels-rs@d9a250a518 (2026-08-16).
Data as JSON: /api/errors/6ea9a7cf75515f3c.
Report an issue: GitHub.