DioxusLabs / dioxus

App framework for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
20.43k stars 786 forks source link

rsx macro fails to parse with confusing error message: missing trailing comma #2276

Closed hkBst closed 2 months ago

hkBst commented 5 months ago

Problem rsx macro fails to parse with confusing error message

Steps To Reproduce This code

use dioxus::prelude::*;

fn main() {
    launch(app);
}

fn app() -> Element {
    rsx!(
        div { class: "game",
            div { class: "board", board }
            div { class: "state", game.with(|g| g.state().to_string()), }
        }
    )
}

produces this error when running dx serve:

\ ⚙️ Compiling dioxus 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)                                                                                                                                                                                                                                           error: missing trailing comma
  --> src/main.rs:11:35
   |
11 |             div { class: "state", game.with(|g| g.state().to_string()), }
   |                                   ^^^^

error: could not compile `test-dioxus-web-rsx` (bin "test-dioxus-web-rsx") due to 1 previous error
Error: 🚫 Serving project failed:

Caused by:
    Build failed

Environment:

Questionnaire

jkelleyrtp commented 5 months ago

The errors need to be better here but expressions must be wrapped in curly braces.

hkBst commented 5 months ago

Thanks, that is very helpful. I am porting from 0.4 and trying to follow the migration guides, but I don't recall seeing this information.

Anyway, that seems to have been the missing piece for me to complete my migration. Thanks again!