{"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":320,"sourceCode":"                    if path_type == PathType::Function\n                        && path.segments.len() == 1\n                        && !input.peek(Paren)\n                    {\n                        BsnScene::Expression(path.to_token_stream())\n                    } else {\n                        let args = input.parse::<BsnFnArgs>()?;\n                        BsnScene::Fn(BsnSceneFn { path, args })\n                    }\n                }\n                path_type => {\n                    return Err(syn::Error::new(\n                        path.span(),\n                        format!(\n                            \"Scenes with path {} of type {:?} are not supported\",\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,\n            PathType::Enum | PathType::TypeConst => take_last_path_ident(&mut path),\n            PathType::Function | PathType::TypeFunction => {\n                return Err(syn::Error::new(\n                    path.span(),\n                    \"Expected a path to a BSN type but encountered a path to a function.\",\n                ))\n            }","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/bevyengine/bevy/blob/a62cce8c05ceacd3bd102e678c83e2b42e5dfbe2/crates/bevy_scene/macros/src/bsn/parse.rs#L302-L338","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":"a62cce8c05ceacd3bd102e678c83e2b42e5dfbe2","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}