antoyo / relm

Idiomatic, GTK+-based, GUI library, inspired by Elm, written in Rust
MIT License
2.41k stars 79 forks source link

Make a clearer error message for View Macro #307

Open RampedIndent opened 1 year ago

RampedIndent commented 1 year ago

Currently if there is invalid data entered into the view!() macro the below error shows up at #[widget]

65 | #[widget]
   | ^^^^^^^^^
   |
   = help: message: should be an ident: Error("expected identifier")

Ideally this error should highlight the invalid data. Or the error message could be clarified that the unexpected identifier is in the view macro. Since a large quantity of code can be in the impl block below #[widget]

This invalid data could include like show below if you put an if statement.

#[widget]
impl Widget for Win {
  // misc code here
  // .....
  view!(){
    gtk::Entry {
        editable: self.model.publish_path_generate.eq(&false).to_owned(),
         if &self.model.publish_path_generate{
             text: &self.model.publish_path,
         } else {
             text: &self.publish_path_custom,
         }
        changed(entry) => {
            let text = entry.text().to_string();
            Msg::TextEntered(text, TextInputFields::PublishPath)
        },
    },
  }
}