slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.55k stars 601 forks source link

slint-build: Multiple exports are silently ignored #4437

Closed DoumanAsh closed 9 months ago

DoumanAsh commented 9 months ago
export component Main2 inherits Window {
}

export component Main1 inherits Window {
}

Then given the following code:

slint::include_modules!();

fn main {
    let main = Main1::new().expect("Create UI");
    let main = Main2::new().expect("Create UI");
}

I get error:

  --> src/main.rs:14:16
   |
14 |     let main = Main2::new().expect("Create UI");
   |                ^^^^^
   |                |
   |                use of undeclared type `Main2`
   |                help: a struct with a similar name exists: `Main1`

Then If I change order to have Main1 as first component, then error will be reversed. So it seems inline export of component actually gets overshadowed by builder as I checked generated code and there is no declaration of second component

I'm not sure if it is intended behavior, but it seems to be quite error prone and probably should be clarified (error out if second export overshadows another export)

ogoffart commented 9 months ago

Thanks for filling a bug.

This is a duplicate of https://github.com/slint-ui/slint/issues/784