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.64k stars 607 forks source link

LSP and viewer panic when doing a for loop on an empty array #6760

Closed jturcotte closed 1 week ago

jturcotte commented 1 week ago
export component Win inherits Window {
    VerticalLayout {
        // Doesn't crash if the array is non-empty
        // but when using the LSP I usually start typing with an empty array
        for i in []:
        Text { text: "bip"; }
    }
}
thread 'main' panicked at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/slint-interpreter-1.8.0/dynamic_item_tree.rs:1178:41:
bad type Void
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: slint_interpreter::dynamic_item_tree::generate_item_tree::property_info_for_type
   3: slint_interpreter::dynamic_item_tree::generate_item_tree
   4: <slint_interpreter::dynamic_item_tree::generate_item_tree::TreeBuilder as i_slint_compiler::generator::ItemTreeBuilder>::push_repeated_item
   5: i_slint_compiler::generator::build_item_tree::visit_item
   6: i_slint_compiler::generator::build_item_tree::visit_children
   7: i_slint_compiler::generator::build_item_tree
   8: slint_interpreter::dynamic_item_tree::generate_item_tree
   9: slint_interpreter::api::Compiler::build_from_path::{{closure}}
  10: spin_on::spin_on
  11: slint_viewer::main
ogoffart commented 1 week ago

Thanks for filing a bug