sycamore-rs / sycamore

A library for creating reactive web apps in Rust and WebAssembly
https://sycamore-rs.netlify.app
MIT License
2.79k stars 148 forks source link

Improve compiler suggestions for invalid binding #498

Closed danielalvsaaker closed 1 year ago

danielalvsaaker commented 1 year ago

Trying to bind a type which isn't a signal using the view macro results in pretty bad compiler suggestions. Generating fully qualified function calls should improve these errors and suggest using signals.

Will also prevent accidentally binding types which coincidentally implements a get and set method.

error[E0599]: no method named `set` found for type `bool` in the current scope
  --> examples/hello-world/src/main.rs:5:5
   |
5  | /     view! { cx,
6  | |         p {
7  | |             input(bind:value=false)
8  | |             "Hello World!"
9  | |         }
10 | |     }
   | |_____^ method not found in `bool`
   |
   = note: this error originates in the macro `view` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider wrapping the receiver expression with the appropriate type
   |
7  |             input(bind:value=Pin::new(&mut false))
   |