bevyengine/bevy · error · syn::Error
Expected a path to a BSN type but encountered a path to a fu
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.
Source
Thrown at crates/bevy_scene/macros/src/bsn/parse.rs:297
"Cannot cache path {} of type {:?}",
path_to_string(&path),
path_type,
),
))
}
}
})
}
}
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 => 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 | PathType::TypeConst => {
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,
enum_variant,
fields,
})
}View on GitHub (pinned to 396ca72708)
Solutions
- Remove the '@' and call the function as a scene function: my_scene_fn()
- If you meant a scene component, use the actual type name after '@': @MySceneComponent
- 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
- Use '@' only before type names, never before functions
- Scene factory functions go bare: spawn_tree(5)
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
- Caching entries after the first is not supported, remove the
- Scene component {} needs to be prefixed by '@'
- Cannot cache Scene function with arguments
- Cannot cache path {} of type {:?}
- Consts are not currently supported in this position
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/47f7bf8c978283cb.
Report an issue: GitHub.