dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

Braced expressions followed by a method don't parse

Open ealmloff opened this issue 11 months ago • 1 comments

Problem

The rsx macro doesn't handle braced expressions correctly

Reproduction

This code fails to compile

// [dependencies]
// dioxus = { version = "0.6" }
use dioxus::prelude::*;

fn main() {
    rsx! {
        div {
            width: {"100%"}.to_string()
        }
    };
}

Expected behavior

The code should compile and run

Environment:

  • Dioxus version: 0.6, and main
  • Rust version: nightly
  • OS info: macOS
  • App platform: all

ealmloff avatar Apr 02 '25 13:04 ealmloff

Changing it to:

// [dependencies]
// dioxus = { version = "0.6" }
use dioxus::prelude::*;

fn main() {
    rsx! {
        div {
            width: {{"100%"}.to_string()}
        }
    };
}

makes the code compile but gives an "unnecessary braces" warning. This could be a workaround for people facing this issue.

jjvn84 avatar Apr 12 '25 16:04 jjvn84

Fixed by #4035

ealmloff avatar May 02 '25 13:05 ealmloff