{"record":{"id":"04b11af07dc2fc29","repo":"bevyengine/bevy","slug":"cannot-cache-scene-expressions","errorCode":null,"errorMessage":"Cannot cache scene expressions","messagePattern":"Cannot cache scene expressions","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bevy_scene/macros/src/bsn/parse.rs","lineNumber":287,"sourceCode":"    }\n}\n\ncustom_punctuation!(TwoMinus, --);\n\nimpl Parse for BsnSceneListItem {\n    fn parse(input: ParseStream) -> Result<Self> {\n        Ok(if input.peek(Brace) {\n            let tokens = braced_tokens(input)?;\n            BsnSceneListItem::Expression(tokens)\n        } else {\n            BsnSceneListItem::Scene(input.parse::<Bsn>()?)\n        })\n    }\n}\n\nimpl BsnScene {\n    fn parse(input: ParseStream) -> Result<Self> {\n        Ok(if input.peek(LitStr) {\n            let path = input.parse::<LitStr>()?;\n            BsnScene::Asset(path)\n        } else if input.peek(Brace) {\n            BsnScene::Expression(braced_tokens(input)?)\n        } else {\n            // PERF: do we really need this fork here?\n            let path = input.fork().parse::<Path>()?;\n            let path_type = PathType::new(&path);\n            match path_type {\n                PathType::Type | PathType::Enum => {\n                    BsnScene::SceneComponent(input.parse::<BsnType>()?)\n                }\n                PathType::Function | PathType::TypeFunction => {\n                    let path = input.parse::<Path>()?;\n                    if path_type == PathType::Function\n                        && path.segments.len() == 1\n                        && !input.peek(Paren)\n                    {","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/bevyengine/bevy/blob/a62cce8c05ceacd3bd102e678c83e2b42e5dfbe2/crates/bevy_scene/macros/src/bsn/parse.rs#L269-L305","documentation":"BsnScene::parse handles braced scene expressions ({ ... }) as BsnScene::Expression, and err_if_cached rejects them when a ':' cache prefix was given: inline expressions cannot be cached. Note the source order: the earlier 'only scene assets' check (parse.rs:229-231) fires first for any non-string-literal after ':', so today this specific message is the designated guard for when that earlier restriction is lifted and expression caching is the remaining gap.","triggerScenarios":"Writing :{ scene_expression } — a braced expression with the cache prefix — in bsn!/bsn_list! (currently surfaced as the 'only scene assets' error due to the earlier check).","commonSituations":"Trying to cache the result of a computed/inline scene expression; assuming BSN caching covers everything the macro can express.","solutions":["Remove the ':' from the expression: { scene_expression }","If you want caching, move the expression's content into a scene asset file and reference it as :\"path.scene\""],"exampleFix":"// before\nbsn!(:{ my_built_scene });\n\n// after\nbsn!({ my_built_scene });","handlingStrategy":"validation","validationCode":"// Rule: braced scene expressions { ... } must be written uncached (no ':').\n// If caching is needed, externalize the expression into a .scene asset file.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never prefix braced expressions with ':'","Move cacheable content into scene asset files referenced as :\"file.scene\""],"tags":["bevy","bsn","proc-macro","scene-expression","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"}