bevyengine/bevy · error · syn::Error

Expected a path to a BSN type but encountered a path to a…

Error message

Expected a path to a BSN type but encountered a path to a function.

What it means

Compile-time error from the bsn! macro when parsing a BsnType. After the parser expects a type path (typically right after '@' for a scene component, or wherever a BSN type is required), PathType::new classified the path as a function or type-function. BSN types must be actual types; functions belong in uncalled scene-function position.

Solutions

  1. Remove the '@' and call the function as a scene function: my_scene_fn()
  2. If you meant a scene component, use the actual type name after '@': @MySceneComponent
  3. Check for accidental parentheses or turbofish syntax that makes the path look like a function

Example fix

// before
bsn! { @spawn_tree(5) }

// after
bsn! { spawn_tree(5) }
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Putting '@' in front of a function, e.g. bsn! { @my_scene_fn() }, because the BsnType parser then receives a function path. Also any other context that parses BsnType and is handed a function path.

Common situations: Confusing the '@' scene-component marker with a general 'spawn this' marker and applying it to factory functions; renaming a type to a function without updating the BSN source.

Related errors


AI-assisted analysis of bevyengine/bevy@a62cce8c05 (2026-08-20). Data as JSON: /api/errors/47f7bf8c978283cb. Report an issue: GitHub.

Appendix: source

Thrown at crates/bevy_scene/macros/src/bsn/parse.rs:341

        })
    }
}

impl Parse for BsnType {
    fn parse(input: ParseStream) -> Result<Self> {
        let mut path = input.parse::<Path>()?;
        let enum_variant = match PathType::new(&path) {
            PathType::Type => None,
            PathType::Enum | PathType::TypeConst => take_last_path_ident(&mut path),
            PathType::Function | PathType::TypeFunction => {
                return Err(syn::Error::new(
                    path.span(),
                    "Expected a path to a BSN type but encountered a path to a function.",
                ))
            }
            PathType::Const => {
                return Err(syn::Error::new(
                    path.span(),
                    "Expected a path to a BSN type but encountered a path to a const.",
                ))
            }
        };
        let fields = input.parse::<BsnFields>()?;
        Ok(BsnType {
            path,
            variant: enum_variant,
            fields,
        })
    }
}

impl Parse for BsnStructUpdate {
    fn parse(input: ParseStream) -> Result<Self> {
        input.parse::<Dot>()?;
        input.parse::<Dot>()?;
        Ok(BsnStructUpdate {

View on GitHub (pinned to a62cce8c05)