DioxusLabs/dioxus · error · syn::Error

Expected an expression

Error message

Expected an expression

What it means

Error "Expected an expression" thrown in DioxusLabs/dioxus.

Source

Thrown at packages/rsx/src/attribute.rs:655

                block.span(),
                "Expected a single statement in the if block",
            ));
        }

        // either an ifmt or an expr in the block
        let stmt = &stmts[0];

        // Either it's a valid ifmt or an expression
        match stmt {
            syn::Stmt::Expr(exp, None) => {
                // Try parsing the statement as an IfmtInput by passing it through tokens
                let value: Result<HotLiteral, syn::Error> = syn::parse2(exp.to_token_stream());
                Ok(match value {
                    Ok(res) => Box::new(AttributeValue::AttrLiteral(res)),
                    Err(_) => Box::new(AttributeValue::AttrExpr(PartialExpr::from_expr(exp))),
                })
            }
            _ => Err(syn::Error::new(stmt.span(), "Expected an expression")),
        }
    }

    fn to_tokens_with_terminated(
        &self,
        tokens: &mut TokenStream2,
        terminated: bool,
        contains_expression: bool,
    ) {
        let IfAttributeValue {
            if_expr,
            then_value,
            else_value,
            ..
        } = self;

        // Quote an attribute value and convert the value to a string if it is formatted
        // We always quote formatted segments as strings inside if statements so they have a consistent type

View on GitHub (pinned to 393d190a80)

When it happens

Trigger: Thrown at packages/rsx/src/attribute.rs:655 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@393d190a80 (2026-08-16). Data as JSON: /api/errors/a5602b5567b5f555. Report an issue: GitHub.