{"record":{"id":"5b6a5d831f2c394d","repo":"bevyengine/bevy","slug":"cannot-cache-path-of-type","errorCode":null,"errorMessage":"Cannot cache path {} of type {:?}","messagePattern":"Cannot cache path (.+?) of type (.+?)","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bevy_scene/macros/src/bsn/parse.rs","lineNumber":276,"sourceCode":"                    // If this path is hit, that means it wasn't prefixed by @\n                    return Err(syn::Error::new(\n                        path.span(),\n                        format!(\n                            \"Scene component {} needs to be prefixed by '@'\",\n                            path_to_string(&path),\n                        ),\n                    ));\n                }\n                PathType::Function | PathType::TypeFunction => {\n                    let path = input.parse::<Path>()?;\n                    let args = input.parse::<BsnFnArgs>()?;\n                    if !args.0.is_empty() {\n                        err_if_cached(\"Cannot cache Scene function with arguments\")?;\n                    }\n                    BsnScene::Fn(BsnSceneFn { path, args })\n                }\n                path_type => {\n                    return Err(syn::Error::new(\n                        path.span(),\n                        format!(\n                            \"Cannot cache path {} of type {:?}\",\n                            path_to_string(&path),\n                            path_type,\n                        ),\n                    ))\n                }\n            }\n        })\n    }\n}\n\nimpl Parse for BsnType {\n    fn parse(input: ParseStream) -> Result<Self> {\n        let mut path = input.parse::<Path>()?;\n        let enum_variant = match PathType::new(&path) {\n            PathType::Type => None,","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_scene/macros/src/bsn/parse.rs#L258-L294","documentation":"Compile-time error from the bsn! macro. In scene position the parser resolved the path to a const or type-const (PathType::Const / PathType::TypeConst), which is not a valid scene. The message mentions caching because the checked fork exists to enforce cache constraints, but this arm fires for any const path in scene position, cached or not.","triggerScenarios":"Writing a const path where a scene is expected, e.g. bsn! { Children [MY_SCENE] } where MY_SCENE is a const. The Type/Enum and Function/TypeFunction arms are skipped, the catch-all path_type arm matches Const/TypeConst, and the error is returned.","commonSituations":"Using a const as an indirection for a scene value; leftover experiment code; assuming any Rust value that implements Scene can be named directly in BSN.","solutions":["Replace the const with a type implementing Scene used as @Type, or a scene function called as my_fn()","If the const holds a value you need, move it into a component's field value instead of scene position","Remove the entry if it is dead code"],"exampleFix":"// before\nconst MY_SCENE: Handle<ScenePatch> = ...;\nbsn! { Children [MY_SCENE] }\n\n// after\nbsn! { Children [:\"my_scene.scn\"] }","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never place const paths in scene position in BSN — only types ('@Type'), functions ('fn()'), or asset paths (':\"file.ext\"')","Put constant values inside component field expressions instead"],"tags":["bevy","bsn","proc-macro","const","scene"],"backgroundTag":"rust-macro-parse-error","analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}