Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler crash: unreachable!() hit #1132

Closed
rdrpenguin04 opened this issue Mar 31, 2022 · 2 comments · Fixed by #1133
Closed

Compiler crash: unreachable!() hit #1132

rdrpenguin04 opened this issue Mar 31, 2022 · 2 comments · Fixed by #1133
Assignees
Labels
a:compiler Slint compiler internal (not the codegen, not the parser) bug Something isn't working

Comments

@rdrpenguin04
Copy link
Contributor

... All of them.

Code:

import { Button, HorizontalBox, ListView, ScrollView, VerticalBox } from "std-widgets.slint";

export struct VisualTreeNode := {
    expanded: bool,
    id: int,
    indent: int,
    name: string,
}

export struct SubMenuItem := {
    name: string,
}

export struct MenuItem := {
    name: string,
    children: [SubMenuItem],
}

Main := Window {
    property<length> tree-view-item-height: 20px;
    property<[VisualTreeNode]> tree: [];
    callback expand(int, bool);
    property<[MenuItem]> menu-items;
    callback menu-button-clicked(string);
    preferred-width: 1280px;
    preferred-height: 720px;
    VerticalBox {
        HorizontalBox {
            height: 15px;
            for menu-item in menu-items : VerticalBox {
                Rectangle { 
                    Text {
                        text: menu-item.name;
                    }
                    TouchArea {
                        clicked => {
                            popup.show();
                            menu-button-clicked(menu-item.name);
                        }
                    }
                }
                popup := PopupWindow {
                    VerticalBox {
                        for child in menu-item.children : Text {
                            text: child.name;
                        }
                    }
                }
            }
            Rectangle {
                horizontal-stretch: 1;
            }
        }
        HorizontalBox {
            ListView {
                width: 25%;
                for node in root.tree : HorizontalLayout {
                    height: tree-view-item-height;
                    padding-left: node.indent * tree-view-item-height * 2;
                    Button {
                        width: tree-view-item-height * 3 / 4;
                        text: node.expanded ? "-" : "+";
                        clicked => {
                            node.expanded = !node.expanded;
                            root.expand(node.id, node.expanded);
                        }
                    }
                    Text {
                        text: node.name;
                        font-size: tree-view-item-height * 3 / 4;
                    }
                }
            }
            VerticalBox {
                width: 50%;
                Text { text: "Hello"; }
            }
        }
    }
}

Error:

  process didn't exit successfully: `/home/rdrpenguin/OpenDisasm/target/debug/build/od_gui_slint-f402580c81abcc9e/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at 'internal error: entered unreachable code', /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/llr/lower_to_item_tree.rs:114:48
  stack backtrace:
     0: rust_begin_unwind
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/std/src/panicking.rs:584:5
     1: core::panicking::panic_fmt
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/panicking.rs:143:14
     2: core::panicking::panic
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/panicking.rs:48:5
     3: i_slint_compiler::llr::lower_to_item_tree::LoweredSubComponentMapping::map_property_reference
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/llr/lower_to_item_tree.rs:114:48
     4: i_slint_compiler::llr::lower_expression::ExpressionContext::map_property_reference
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/llr/lower_expression.rs:42:25
     5: i_slint_compiler::llr::lower_expression::lower_expression
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/llr/lower_expression.rs:83:17
     6: i_slint_compiler::llr::lower_expression::lower_show_popup
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/llr/lower_expression.rs:341:24
     7: i_slint_compiler::llr::lower_expression::lower_expression
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/llr/lower_expression.rs:118:17
     8: i_slint_compiler::llr::lower_expression::lower_expression::{{closure}}
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/llr/lower_expression.rs:114:59
     9: core::iter::adapters::map::map_fold::{{closure}}
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/iter/adapters/map.rs:84:28
    10: core::iter::traits::iterator::Iterator::fold
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/iter/traits/iterator.rs:2362:21
    11: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/iter/adapters/map.rs:124:9
    12: core::iter::traits::iterator::Iterator::for_each
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/iter/traits/iterator.rs:779:9
    13: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/alloc/src/vec/spec_extend.rs:40:17
    14: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/alloc/src/vec/spec_from_iter_nested.rs:62:9
    15: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter::SpecFromIter<T,I>>::from_iter
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/alloc/src/vec/spec_from_iter.rs:33:9
    16: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/alloc/src/vec/mod.rs:2552:9
    17: core::iter::traits::iterator::Iterator::collect
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/iter/traits/iterator.rs:1784:9
    18: i_slint_compiler::llr::lower_expression::lower_expression
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/llr/lower_expression.rs:114:39
    19: i_slint_compiler::llr::lower_to_item_tree::lower_sub_component::{{closure}}
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/llr/lower_to_item_tree.rs:293:17
    20: i_slint_compiler::generator::handle_property_bindings_init::handle_property_inner
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/generator.rs:382:9
    21: i_slint_compiler::generator::handle_property_bindings_init::{{closure}}
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/generator.rs:388:13
    22: i_slint_compiler::object_tree::recurse_elem
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/object_tree.rs:1423:17
    23: i_slint_compiler::object_tree::recurse_elem
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/object_tree.rs:1425:9
    24: i_slint_compiler::object_tree::recurse_elem
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/object_tree.rs:1425:9
    25: i_slint_compiler::generator::handle_property_bindings_init
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/generator.rs:386:5
    26: i_slint_compiler::llr::lower_to_item_tree::lower_sub_component
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/llr/lower_to_item_tree.rs:286:5
    27: i_slint_compiler::llr::lower_to_item_tree::lower_repeated_component
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/llr/lower_to_item_tree.rs:416:14
    28: i_slint_compiler::llr::lower_to_item_tree::lower_sub_component::{{closure}}
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/llr/lower_to_item_tree.rs:346:41
    29: core::iter::adapters::map::map_fold::{{closure}}
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/iter/adapters/map.rs:84:28
    30: core::iter::traits::iterator::Iterator::fold
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/iter/traits/iterator.rs:2362:21
    31: <core::iter::adapters::map::Map<I,F> as core::iter::traits::iterator::Iterator>::fold
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/iter/adapters/map.rs:124:9
    32: core::iter::traits::iterator::Iterator::for_each
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/iter/traits/iterator.rs:779:9
    33: <alloc::vec::Vec<T,A> as alloc::vec::spec_extend::SpecExtend<T,I>>::spec_extend
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/alloc/src/vec/spec_extend.rs:40:17
    34: <alloc::vec::Vec<T> as alloc::vec::spec_from_iter_nested::SpecFromIterNested<T,I>>::from_iter
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/alloc/src/vec/spec_from_iter_nested.rs:62:9
    35: alloc::vec::in_place_collect::<impl alloc::vec::spec_from_iter::SpecFromIter<T,I> for alloc::vec::Vec<T>>::from_iter
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/alloc/src/vec/in_place_collect.rs:164:20
    36: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/alloc/src/vec/mod.rs:2552:9
    37: core::iter::traits::iterator::Iterator::collect
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/iter/traits/iterator.rs:1784:9
    38: i_slint_compiler::llr::lower_to_item_tree::lower_sub_component
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/llr/lower_to_item_tree.rs:346:9
    39: i_slint_compiler::llr::lower_to_item_tree::lower_to_item_tree
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/llr/lower_to_item_tree.rs:29:14
    40: i_slint_compiler::generator::rust::generate
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/internal/compiler/generator/rust.rs:117:15
    41: slint_build::compile_with_config
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/0ca2394/api/rs/build/lib.rs:250:21
    42: build_script_build::main
               at ./build.rs:2:5
    43: core::ops::function::FnOnce::call_once
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/ops/function.rs:227:5

As always, let me know if I can help!

@ogoffart
Copy link
Member

... All of them.

I haven't investigated the bug yet, but i'm pretty sure it's because of the PopupWindow again.
(We're currently only using the PopupWindow for the combobox and it's a bit under-tested as you can see)

As always, thanks for the report.

@ogoffart ogoffart added bug Something isn't working a:compiler Slint compiler internal (not the codegen, not the parser) labels Mar 31, 2022
@rdrpenguin04
Copy link
Contributor Author

Of course; happy to help!

I think that I'm running across these because I'm trying to imitate traditional top-bar menu design, and most users of Slint are going for more modern UI styles. I'm glad to be able to use this UI in any case of course 😄!

Let me know if there's any way I can help with debugging!

@ogoffart ogoffart self-assigned this Apr 1, 2022
ogoffart added a commit that referenced this issue Apr 1, 2022
 * Make sure that the compiler don't panic if the parent of a PopupWindow
   is optimized (by not optiizing such element)

 * Ensure that we can call popup.show() from within a deeper repeater

 * Ensure that the parent element of the popup is the right one in case of
   repeater (and not the node in the parent component)

This partially revert ad5991f and
6c7a7ae because we must do the lower_popup
adter the repeater pass, because otherwise the parent element of the
created component for the PopupWindow might be wrong and it is not easy to
adjust (we would have to make Component::parent_element a RefCell or duplicate
it again.

Fixes #1132
ogoffart added a commit that referenced this issue Apr 1, 2022
 * Make sure that the compiler don't panic if the parent of a PopupWindow
   is optimized (by not optiizing such element)

 * Ensure that we can call popup.show() from within a deeper repeater

 * Ensure that the parent element of the popup is the right one in case of
   repeater (and not the node in the parent component)

This partially revert ad5991f and
6c7a7ae because we must do the lower_popup
adter the repeater pass, because otherwise the parent element of the
created component for the PopupWindow might be wrong and it is not easy to
adjust (we would have to make Component::parent_element a RefCell or duplicate
it again.

Fixes #1132
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:compiler Slint compiler internal (not the codegen, not the parser) bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants