{"record":{"id":"a48f1706379720ee","repo":"bevyengine/bevy","slug":"expected-a-boolean-value","errorCode":null,"errorMessage":"Expected a boolean value","messagePattern":"Expected a boolean value","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"crates/bevy_reflect/derive/src/container_attributes.rs","lineNumber":673,"sourceCode":"    pub fn is_opaque(&self) -> bool {\n        self.is_opaque\n    }\n}\n\n/// Extract a boolean value from an expression.\n///\n/// The mapper exists so that the caller can conditionally choose to use the given\n/// value or supply their own.\nfn extract_bool(\n    value: &Expr,\n    mut mapper: impl FnMut(&LitBool) -> LitBool,\n) -> Result<LitBool, syn::Error> {\n    match value {\n        Expr::Lit(syn::ExprLit {\n            lit: syn::Lit::Bool(lit),\n            ..\n        }) => Ok(mapper(lit)),\n        _ => Err(syn::Error::new(value.span(), \"Expected a boolean value\")),\n    }\n}\n","sourceCodeStart":655,"sourceCodeEnd":676,"githubUrl":"https://github.com/bevyengine/bevy/blob/396ca727080776bd313bb892423b7d94e03b81b4/crates/bevy_reflect/derive/src/container_attributes.rs#L655-L676","documentation":"The boolean reflect attributes (`#[reflect(from_reflect = ...)]`, `#[reflect(type_path = ...)]`) are parsed by `extract_bool` (crates/bevy_reflect/derive/src/container_attributes.rs:665), which only accepts a literal `true`/`false` (`syn::Lit::Bool`). Any other expression — a string, an integer, a path, or a constant — fails with the compile error \"Expected a boolean value\" pointing at the value's span.","triggerScenarios":"Writing `#[reflect(type_path = \"false\")]`, `#[reflect(from_reflect = 1)]`, `#[reflect(from_reflect = SHOULD_DERIVE)]`, or any non-literal-boolean expression as the attribute value.","commonSituations":"Porting old attribute syntax that used other literal kinds; macro code substituting a variable into the attribute value (proc macros see tokens, not runtime values); typoed values.","solutions":["Use the literal keywords `true` or `false` directly","If the value comes from a macro, pass the literal through as tokens (e.g. a `bool`-typed macro rule `$v:literal`) instead of computing it"],"exampleFix":"// before\n#[reflect(from_reflect = \"false\")] // or = 1, or = SOME_CONST\n\n// after\n#[reflect(from_reflect = false)]","handlingStrategy":"validation","validationCode":"null","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Attribute values must be literal `true`/`false` tokens — never strings, numbers, or constants","In declarative macros, pass booleans as `$v:literal` tokens rather than interpolating computed values"],"tags":["bevy","reflect","derive-macro","attribute-syntax","compile-error"],"backgroundTag":"invalid-derive-attribute-literal","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"}