bevyengine/bevy · error · syn::Error
Expected a path to a BSN type but encountered a path to a co
Error message
Expected a path to a BSN type but encountered a path to a const.
What it means
Compile-time error from the bsn! macro when parsing a BsnType. The parser expected a path to a type but PathType::new classified it as a const or type-const. BSN type positions accept types (and enum variants), never consts.
Source
Thrown at crates/bevy_scene/macros/src/bsn/parse.rs:356
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 {
value: Box::new(input.parse::<BsnValue>()?),
})
}
}
impl Parse for BsnTuple {View on GitHub (pinned to 8d743eb7dc)
Solutions
- Use the actual type name in the BSN source: @MySceneComponent instead of a const alias
- If the identifier is really a type but named in SCREAMING_CASE, rename it to CamelCase so PathType classifies it as a type
- If it is genuinely a const value, move it into an expression position (field value) rather than type position
Example fix
// before
bsn! { @MY_SCENE_TYPE }
// after
bsn! { @MySceneType } Defensive patterns
Strategy: validation
Prevention
- Use a type name (CamelCase) after '@', not a const (SCREAMING_CASE)
- Be aware PathType classification is naming-convention driven: uppercase identifiers look like consts
When it happens
Trigger: Writing a const where a BSN type is expected, most commonly right after '@', e.g. bsn! { @MY_SCENE_TYPE }. The BsnType parser parses the path, sees PathType::Const/TypeConst, and returns this error.
Common situations: Trying to indirect a type name through a const; uppercase naming that makes a type look like a const (PathType heuristics classify SCREAMING_CASE identifiers as consts); leftover refactoring debris.
Related errors
- Consts are not currently supported in this position
- Cannot cache path {} of type {:?}
- Currently, caching is only supported for scene assets. Pleas
- Cannot use scene assets without caching, please add the ':'
- Caching entries after the first is not supported, remove the
AI-assisted analysis of bevyengine/bevy@8d743eb7dc (2026-08-20).
Data as JSON: /api/errors/ba421f7f8839b99b.
Report an issue: GitHub.