{"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":243,"sourceCode":"        // and how there doesn't seem to be a need for all the specific `err_if_cached`\n        // in later code. But since caching is planned, and will very likely\n        // have the limitations which are ensured by the other errors below,\n        // this is its own block so its very simple to remove once caching is implemented.\n        if !input.peek(LitStr) {\n            err_if_cached(\"Currently, caching is only supported for scene assets. Please remove the ':' prefix for now.\")?;\n        }\n\n        Ok(if input.peek(LitStr) {\n            let path = input.parse::<LitStr>()?;\n            if cached.is_none() {\n                return Err(syn::Error::new(\n                    path.span(),\n                    \"Cannot use scene assets without caching, please add the ':' prefix.\",\n                ));\n            }\n            BsnScene::Asset(path)\n        } else if input.peek(Brace) {\n            err_if_cached(\"Cannot cache scene expressions\")?;\n            BsnScene::Expression(braced_tokens(input)?)\n        } else if input.peek(At) {\n            input.parse::<At>()?;\n            let sc = input.parse::<BsnType>()?;\n            if sc.fields.len() > 0 {\n                err_if_cached(\"Cannot cache Scene Components with props/fields\")?;\n            }\n            BsnScene::SceneComponent(sc)\n        } else {\n            // PERF: do we really need this fork here?\n            let path = input.fork().parse::<Path>()?;\n            match PathType::new(&path) {\n                PathType::Type | PathType::Enum => {\n                    // Scene components are parsed before this if an @ is found.\n                    // If this path is hit, that means it wasn't prefixed by @\n                    return Err(syn::Error::new(\n                        path.span(),\n                        format!(","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_scene/macros/src/bsn/parse.rs#L225-L261","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":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}