bevyengine/bevy · error · syn::Error
Consts are not currently supported in this position
Error message
Consts are not currently supported in this position
What it means
When a BSN entry is parsed as a plain path, PathType::new classifies it. A bare const path (PathType::Const — a lone identifier resolving to a constant, not associated with a type) is rejected in entry position with this compile-time syn::Error. Only types, enum variants, associated consts (Type::CONST, PathType::TypeConst) and functions are accepted there.
Solutions
- Use an associated const on a type: bsn!(MyType::MY_CONST) — PathType::TypeConst is supported as a template const
- Or wrap the value in a component/scene-component form the macro supports (e.g. @MySceneComponent or a function call constructor MyType::new(args))
Example fix
// before
const PLAYER_SPAWN: Spawn = ...;
bsn!(PLAYER_SPAWN); // PathType::Const -> error
// after
impl Player { const SPAWN: Spawn = ...; }
bsn!(Player::SPAWN); // PathType::TypeConst -> template const Defensive patterns
Strategy: type-guard
Validate before calling
// Before using a const in BSN, make it an associated const:
// impl MyType { pub const VALUE: MyType = ...; }
// then reference MyType::VALUE, which parses as PathType::TypeConst. Type guard
fn is_associated_const(path: &str) -> bool {
path.split("::").count() >= 2
} Prevention
- Use Type::CONST (associated const) instead of free consts in BSN entries
- Uppercase single-segment identifiers in BSN are treated as consts and rejected — prefer types or functions
When it happens
Trigger: Writing bsn!(MY_CONST) or bsn!(MY_PATH::CONST) where the last segment is a free-standing const (e.g. a crate-level constant), instead of an associated const on a type.
Common situations: Trying to reference pre-made component values as consts in BSN; confusing a module-level const with a type's associated const; name collisions where an uppercase identifier is actually a const.
Related errors
- Caching entries after the first is not supported, remove…
- Cannot cache path of type
- Cannot cache Scene Components with props/fields
- Cannot cache scene expressions
- Cannot use scene assets without caching, please add the ':'…
AI-assisted analysis of bevyengine/bevy@a62cce8c05 (2026-08-20).
Data as JSON: /api/errors/99c2ad21f00f148a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/bevy_scene/macros/src/bsn/parse.rs:153
let variant = if matches!(path_type, PathType::Enum | PathType::TypeConst) {
take_last_path_ident(&mut path)
} else {
None
};
if input.peek(Bracket) {
// TODO: fail if this is an enum variant
BsnEntry::RelatedSceneList(BsnRelatedSceneList {
relationship_path: path,
scene_list: input.parse::<BsnSceneList>()?,
})
} else {
let fields = input.parse::<BsnFields>()?;
let bsn_type = BsnType {
path,
variant,
fields,
};
if is_template {
BsnEntry::TemplatePatch(bsn_type)
} else {
if input.peek(Dot) {
let end_cursor = input.cursor();
let dot_expr = parse_extended_dot_expression(input)?;
let tokens = tokens_between(start_type, end_cursor);
BsnEntry::TemplateValue(quote! {#tokens #dot_expr})
} else {
BsnEntry::FromTemplatePatch(bsn_type)
}
}
}
}
PathType::Const => BsnEntry::TemplateValue(path.to_token_stream()),
PathType::TypeFunction => {
let function = take_last_path_ident(&mut path).unwrap();
let args = input.parse::<BsnFnArgs>()?;
let constructor = BsnConstructor {View on GitHub (pinned to a62cce8c05)