bevyengine/bevy · error · syn::Error

Scene component needs to be prefixed by '@

Error message

Scene component {} needs to be prefixed by '@'

What it means

This is a compile-time error from the bsn! macro's parser (bevy_scene/macros). While parsing a scene entry, the parser resolved a Rust path that refers to a type or enum, but only types preceded by '@' are accepted as scene components in scene position (e.g. inside Children [...] lists). The '@' prefix is how BSN distinguishes a scene component (a type implementing Scene) from a plain component.

Solutions

  1. Prefix the scene component with '@': Children [@MySceneComponent]
  2. If the path is meant to be a regular component (not a Scene impl), keep it without '@' but make sure it sits in component position, not in a scene list position
  3. If the path is meant to be a scene-producing function, call it like a function (my_scene_fn()) so it parses as BsnScene::Fn

Example fix

// before
bsn! {
  #Player
  Children [
    MySceneComponent   // a type implementing Scene, missing '@'
    Score(10)
  ]
}

// after
bsn! {
  #Player
  Children [
    @MySceneComponent
    Score(10)
  ]
}
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: Writing a type path in scene/list position inside bsn! without the '@' prefix, e.g. bsn! { Children [MySceneComponent Score(10)] } where MySceneComponent is a type. The parser forks, parses the path, PathType::new reports Type or Enum, and since the '@' branch was not taken earlier, this error is returned.

Common situations: Authors learning BSN syntax who assume scene components are written like normal components; migrating code from an older bevy_scene DSL that had no '@' marker; typos where the '@' was simply forgotten.

Related errors


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

Appendix: source

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

impl BsnScene {
    fn parse(input: ParseStream) -> Result<Self> {
        Ok(if input.peek(LitStr) {
            let path = input.parse::<LitStr>()?;
            BsnScene::Asset(path)
        } else if input.peek(Brace) {
            BsnScene::Expression(braced_tokens(input)?)
        } else {
            // PERF: do we really need this fork here?
            let path = input.fork().parse::<Path>()?;
            let path_type = PathType::new(&path);
            match path_type {
                PathType::Type | PathType::Enum => {
                    BsnScene::SceneComponent(input.parse::<BsnType>()?)
                }
                PathType::Function | PathType::TypeFunction => {
                    let path = input.parse::<Path>()?;
                    if path_type == PathType::Function
                        && path.segments.len() == 1
                        && !input.peek(Paren)
                    {
                        BsnScene::Expression(path.to_token_stream())
                    } else {
                        let args = input.parse::<BsnFnArgs>()?;
                        BsnScene::Fn(BsnSceneFn { path, args })
                    }
                }
                path_type => {
                    return Err(syn::Error::new(
                        path.span(),
                        format!(
                            "Scenes with path {} of type {:?} are not supported",
                            path_to_string(&path),
                            path_type,
                        ),
                    ))
                }

View on GitHub (pinned to a62cce8c05)