{"record":{"id":"6163ff42f263a389","repo":"DioxusLabs/dioxus","slug":"expected-a-single-statement-in-the-if-block","errorCode":null,"errorMessage":"Expected a single statement in the if block","messagePattern":"Expected a single statement in the if block","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"packages/rsx/src/attribute.rs","lineNumber":550,"sourceCode":"            match expr {\n                AttributeValue::IfExpr(if_expr) => if_expr.contains_expression(),\n                AttributeValue::AttrLiteral(_) => false,\n                _ => true,\n            }\n        }\n\n        attribute_value_contains_expression(&self.then_value)\n            || self\n                .else_value\n                .as_deref()\n                .is_some_and(attribute_value_contains_expression)\n    }\n\n    fn parse_attribute_value_from_block(block: &Block) -> syn::Result<Box<AttributeValue>> {\n        let stmts = &block.stmts;\n\n        if stmts.len() != 1 {\n            return Err(syn::Error::new(\n                block.span(),\n                \"Expected a single statement in the if block\",\n            ));\n        }\n\n        // either an ifmt or an expr in the block\n        let stmt = &stmts[0];\n\n        // Either it's a valid ifmt or an expression\n        match stmt {\n            syn::Stmt::Expr(exp, None) => {\n                // Try parsing the statement as an IfmtInput by passing it through tokens\n                let value: Result<HotLiteral, syn::Error> = syn::parse2(exp.to_token_stream());\n                Ok(match value {\n                    Ok(res) => Box::new(AttributeValue::AttrLiteral(res)),\n                    Err(_) => Box::new(AttributeValue::AttrExpr(PartialExpr::from_expr(exp))),\n                })\n            }","sourceCodeStart":532,"sourceCodeEnd":568,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/24f6a829df0dfa203961a98ea4cae21c2ff27e28/packages/rsx/src/attribute.rs#L532-L568","documentation":"An attribute value written as a block `{ ... }` inside an if/else attribute branch contained zero or multiple statements. The RSX parser needs exactly one expression (or format string) per block to build the attribute value.","triggerScenarios":"Thrown at packages/rsx/src/attribute.rs:550 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the if block in the attribute to a single statement or expression; multiple statements are not supported there."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"24f6a829df0dfa203961a98ea4cae21c2ff27e28","analyzedAt":"2026-08-23T07:10:14.078Z","contentChangedAt":"2026-08-23T07:10:14.078Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}