{"record":{"id":"47f7bf8c978283cb","repo":"bevyengine/bevy","slug":"expected-a-path-to-a-bsn-type-but-encountered-a-pa","errorCode":null,"errorMessage":"Expected a path to a BSN type but encountered a path to a function.","messagePattern":"Expected a path to a BSN type but encountered a path to a function\\.","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bevy_scene/macros/src/bsn/parse.rs","lineNumber":297,"sourceCode":"                            \"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,\n            PathType::Enum => 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            }\n            PathType::Const | PathType::TypeConst => {\n                return Err(syn::Error::new(\n                    path.span(),\n                    \"Expected a path to a BSN type but encountered a path to a const.\",\n                ))\n            }\n        };\n        let fields = input.parse::<BsnFields>()?;\n        Ok(BsnType {\n            path,\n            enum_variant,\n            fields,\n        })\n    }","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_scene/macros/src/bsn/parse.rs#L279-L315","documentation":"Compile-time error from the bsn! macro when parsing a BsnType. After the parser expects a type path (typically right after '@' for a scene component, or wherever a BSN type is required), PathType::new classified the path as a function or type-function. BSN types must be actual types; functions belong in uncalled scene-function position.","triggerScenarios":"Putting '@' in front of a function, e.g. bsn! { @my_scene_fn() }, because the BsnType parser then receives a function path. Also any other context that parses BsnType and is handed a function path.","commonSituations":"Confusing the '@' scene-component marker with a general 'spawn this' marker and applying it to factory functions; renaming a type to a function without updating the BSN source.","solutions":["Remove the '@' and call the function as a scene function: my_scene_fn()","If you meant a scene component, use the actual type name after '@': @MySceneComponent","Check for accidental parentheses or turbofish syntax that makes the path look like a function"],"exampleFix":"// before\nbsn! { @spawn_tree(5) }\n\n// after\nbsn! { spawn_tree(5) }","handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use '@' only before type names, never before functions","Scene factory functions go bare: spawn_tree(5)"],"tags":["bevy","bsn","proc-macro","type-mismatch","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"}