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.
Source
Thrown at crates/bevy_scene/macros/src/bsn/parse.rs:150
enum_variant,
fields,
};
if is_template {
BsnEntry::TemplatePatch(bsn_type)
} else {
BsnEntry::FromTemplatePatch(bsn_type)
}
}
}
PathType::TypeConst => {
let const_ident = take_last_path_ident(&mut path).unwrap();
BsnEntry::TemplateConst {
type_path: path,
const_ident,
}
}
PathType::Const => {
return Err(syn::Error::new(
path.span(),
"Consts are not currently supported in this position",
))
}
PathType::TypeFunction => {
let function = take_last_path_ident(&mut path).unwrap();
let args = input.parse::<BsnFnArgs>()?;
let bsn_constructor = BsnConstructor {
type_path: path,
function,
args,
};
if is_template {
BsnEntry::TemplateConstructor(bsn_constructor)
} else {
BsnEntry::FromTemplateConstructor(bsn_constructor)
}
}View on GitHub (pinned to 396ca72708)
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 the
- Currently, caching is only supported for scene assets. Pleas
- Cannot use scene assets without caching, please add the ':'
- Cannot cache scene expressions
- Cannot cache Scene Components with props/fields
AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20).
Data as JSON: /api/errors/99c2ad21f00f148a.
Report an issue: GitHub.