dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

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

Open hkBst opened this issue 1 year ago • 2 comments

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:

  • Dioxus version: 0.5.1
  • Rust version: 1.76.0
  • OS info: Linux
  • App platform: web

Questionnaire

  • [ ] I'm interested in fixing this myself but don't know where to start
  • [ ] I would like to fix and I have a solution
  • [ ] I don't have time to fix this right now, but maybe later

hkBst avatar Apr 08 '24 17:04 hkBst

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

jkelleyrtp avatar Apr 08 '24 20:04 jkelleyrtp

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!

hkBst avatar Apr 09 '24 13:04 hkBst