{"record":{"id":"99c2ad21f00f148a","repo":"bevyengine/bevy","slug":"consts-are-not-currently-supported-in-this-positio","errorCode":null,"errorMessage":"Consts are not currently supported in this position","messagePattern":"Consts are not currently supported in this position","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bevy_scene/macros/src/bsn/parse.rs","lineNumber":153,"sourceCode":"                    let variant = if matches!(path_type, PathType::Enum | PathType::TypeConst) {\n                        take_last_path_ident(&mut path)\n                    } else {\n                        None\n                    };\n                    if input.peek(Bracket) {\n                        // TODO: fail if this is an enum variant\n                        BsnEntry::RelatedSceneList(BsnRelatedSceneList {\n                            relationship_path: path,\n                            scene_list: input.parse::<BsnSceneList>()?,\n                        })\n                    } else {\n                        let fields = input.parse::<BsnFields>()?;\n                        let bsn_type = BsnType {\n                            path,\n                            variant,\n                            fields,\n                        };\n                        if is_template {\n                            BsnEntry::TemplatePatch(bsn_type)\n                        } else {\n                            if input.peek(Dot) {\n                                let end_cursor = input.cursor();\n                                let dot_expr = parse_extended_dot_expression(input)?;\n                                let tokens = tokens_between(start_type, end_cursor);\n                                BsnEntry::TemplateValue(quote! {#tokens #dot_expr})\n                            } else {\n                                BsnEntry::FromTemplatePatch(bsn_type)\n                            }\n                        }\n                    }\n                }\n                PathType::Const => BsnEntry::TemplateValue(path.to_token_stream()),\n                PathType::TypeFunction => {\n                    let function = take_last_path_ident(&mut path).unwrap();\n                    let args = input.parse::<BsnFnArgs>()?;\n                    let constructor = BsnConstructor {","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/bevyengine/bevy/blob/a62cce8c05ceacd3bd102e678c83e2b42e5dfbe2/crates/bevy_scene/macros/src/bsn/parse.rs#L135-L171","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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))"],"exampleFix":"// before\nconst PLAYER_SPAWN: Spawn = ...;\nbsn!(PLAYER_SPAWN); // PathType::Const -> error\n\n// after\nimpl Player { const SPAWN: Spawn = ...; }\nbsn!(Player::SPAWN); // PathType::TypeConst -> template const","handlingStrategy":"type-guard","validationCode":"// Before using a const in BSN, make it an associated const:\n// impl MyType { pub const VALUE: MyType = ...; }\n// then reference MyType::VALUE, which parses as PathType::TypeConst.","typeGuard":"fn is_associated_const(path: &str) -> bool {\n    path.split(\"::\").count() >= 2\n}","tryCatchPattern":null,"preventionTips":["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"],"tags":["bevy","bsn","proc-macro","const","compile-error"],"backgroundTag":"proc-macro-syntax-error","analyzedSha":"a62cce8c05ceacd3bd102e678c83e2b42e5dfbe2","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}