{"record":{"id":"4a8560b4369a8084","repo":"bevyengine/bevy","slug":"not-supported-in-this-position-please-use-one-of","errorCode":null,"errorMessage":"Not supported in this position, please use one of the following:\n- path to function\n- call to function yielding closure","messagePattern":"Not supported in this position, please use one of the following:\n- path to function\n- call to function yielding closure","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/bevy_ecs/macro_logic/src/component.rs","lineNumber":571,"sourceCode":"impl HookAttributeKind {\n    fn parse(\n        input: syn::parse::ParseStream,\n        default_hook_path: impl FnOnce() -> ExprPath,\n    ) -> Result<Self> {\n        if input.peek(Token![=]) {\n            input.parse::<Token![=]>()?;\n            input.parse::<Expr>().and_then(Self::from_expr)\n        } else {\n            Ok(Self::Path(default_hook_path()))\n        }\n    }\n\n    fn from_expr(value: Expr) -> Result<Self> {\n        match value {\n            Expr::Path(path) => Ok(HookAttributeKind::Path(path)),\n            Expr::Call(call) => Ok(HookAttributeKind::Call(call)),\n            // throw meaningful error on all other expressions\n            _ => Err(syn::Error::new(\n                value.span(),\n                [\n                    \"Not supported in this position, please use one of the following:\",\n                    \"- path to function\",\n                    \"- call to function yielding closure\",\n                ]\n                .join(\"\\n\"),\n            )),\n        }\n    }\n\n    fn to_token_stream(&self, bevy_ecs_path: &Path) -> TokenStream {\n        match self {\n            HookAttributeKind::Path(path) => path.to_token_stream(),\n            HookAttributeKind::Call(call) => {\n                quote!({\n                    fn _internal_hook(world: #bevy_ecs_path::world::DeferredWorld, ctx: #bevy_ecs_path::lifecycle::HookContext) {\n                        (#call)(world, ctx)","sourceCodeStart":553,"sourceCodeEnd":589,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_ecs/macro_logic/src/component.rs#L553-L589","documentation":"Compile-time error from HookAttributeKind::from_expr: the expression given to a component hook attribute (e.g. on_insert/on_remove) is neither a plain path to a hook function nor a call expression that yields a closure; other expression forms (literals, blocks, method chains) are not supported in that position.","triggerScenarios":"Thrown at crates/bevy_ecs/macro_logic/src/component.rs:571 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a path to a function: #[component(on_insert = my_hook)]","Use a call yielding a closure: #[component(on_insert = my_hook_factory())]"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"396ca727080776bd313bb892423b7d94e03b81b4","analyzedAt":"2026-08-20T16:12:39.808Z","contentChangedAt":"2026-08-20T16:12:39.808Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}