bevyengine/bevy · error · syn::Error

`#[reflect("...")]` must use parentheses `(` and `)`

Error message

`#[reflect("...")]` must use parentheses `(` and `)`

What it means

The `#[reflect(...)]` attribute must be a parenthesized list. In `derive_data.rs` (crates/bevy_reflect/derive/src/derive_data.rs:190), a `Meta::List` named `reflect` is accepted only when its delimiter is `MacroDelimiter::Paren`; bracket or brace delimiters — `#[reflect[...]]` or `#[reflect{...}]` — produce the compile error "`#[reflect(\"...\")]` must use parentheses `(` and `)`" at the delimiter's span.

Source

Thrown at crates/bevy_reflect/derive/src/derive_data.rs:203

        input: &'a DeriveInput,
        provenance: ReflectProvenance,
    ) -> Result<Self, syn::Error> {
        let mut container_attributes = ContainerAttributes::default();
        // Should indicate whether `#[type_path = "..."]` was used.
        let mut custom_path: Option<Path> = None;
        // Should indicate whether `#[type_name = "..."]` was used.
        let mut custom_type_name: Option<Ident> = None;

        #[cfg(feature = "reflect_documentation")]
        let mut doc = crate::documentation::Documentation::default();

        for attribute in &input.attrs {
            match &attribute.meta {
                Meta::List(meta_list) if meta_list.path.is_ident(REFLECT_ATTRIBUTE_NAME) => {
                    if let MacroDelimiter::Paren(_) = meta_list.delimiter {
                        container_attributes.parse_meta_list(meta_list, provenance.trait_)?;
                    } else {
                        return Err(syn::Error::new(
                            meta_list.delimiter.span().join(),
                            format_args!(
                                "`#[{REFLECT_ATTRIBUTE_NAME}(\"...\")]` must use parentheses `(` and `)`"
                            ),
                        ));
                    }
                }
                Meta::NameValue(pair) if pair.path.is_ident(TYPE_PATH_ATTRIBUTE_NAME) => {
                    let syn::Expr::Lit(syn::ExprLit {
                        lit: syn::Lit::Str(lit),
                        ..
                    }) = &pair.value
                    else {
                        return Err(syn::Error::new(
                            pair.span(),
                            format_args!("`#[{TYPE_PATH_ATTRIBUTE_NAME} = \"...\"]` must be a string literal"),
                        ));
                    };

View on GitHub (pinned to 396ca72708)

Solutions

  1. Rewrite the attribute with parentheses: `#[reflect(Debug, Default)]`
  2. If a macro generates it, fix the rule to emit `( ... )`

Example fix

// before
#[reflect["Debug"]]
struct Foo;

// after
#[reflect(Debug)]
struct Foo;
Defensive patterns

Strategy: validation

Validate before calling

null

Prevention

When it happens

Trigger: Typos and macro-generated code that emit `#[reflect["Debug"]]`, `#[reflect{Debug}]`, or any reflect list with `[...]`/`{...}` delimiters instead of `(...)`.

Common situations: Hand-writing attributes with mismatched brackets; declarative macro rules that template the delimiter; editors auto-closing the wrong bracket type.

Related errors


AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20). Data as JSON: /api/errors/123092cc4527931f. Report an issue: GitHub.