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 in the generator #1113

Closed
rdrpenguin04 opened this issue Mar 30, 2022 · 1 comment · Fixed by #1119
Closed

Compiler crash in the generator #1113

rdrpenguin04 opened this issue Mar 30, 2022 · 1 comment · Fixed by #1119
Assignees
Labels
a:compiler Slint compiler internal (not the codegen, not the parser) bug Something isn't working

Comments

@rdrpenguin04
Copy link
Contributor

... Why do I keep finding all of the crashes...

Here's my slint 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 { Text {
                text: menu-item.name;
                popup := PopupWindow {
                    VerticalBox {
                        for child in menu-item.children : Text {
                            text: child.name;
                        }
                    }
                }
                TouchArea {
                    clicked => {
                        menu-button-clicked(menu-item.name);
                    }
                }
            } }
        }
        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"; }
            }
        }
    }
}

And here's the panic:

  process didn't exit successfully: `/home/rdrpenguin/OpenDisasm/target/debug/build/od_gui_slint-209520c725cd716c/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at 'Expression::StructFieldAccess's base expression is not an Object type', /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/6622f33/internal/compiler/generator/rust.rs:1604:18
  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: i_slint_compiler::generator::rust::compile_expression
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/6622f33/internal/compiler/generator/rust.rs:1604:18
     3: i_slint_compiler::generator::rust::compile_expression
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/6622f33/internal/compiler/generator/rust.rs:1477:21
     4: i_slint_compiler::generator::rust::generate_sub_component
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/6622f33/internal/compiler/generator/rust.rs:612:25
     5: i_slint_compiler::generator::rust::generate_item_tree
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/6622f33/internal/compiler/generator/rust.rs:997:20
     6: i_slint_compiler::generator::rust::generate_sub_component::{{closure}}
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/6622f33/internal/compiler/generator/rust.rs:534:13
     7: core::iter::adapters::map::map_fold::{{closure}}
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/iter/adapters/map.rs:84:28
     8: core::iter::traits::iterator::Iterator::fold
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/iter/traits/iterator.rs:2362:21
     9: <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
    10: core::iter::traits::iterator::Iterator::for_each
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/iter/traits/iterator.rs:779:9
    11: <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
    12: <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
    13: <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
    14: <alloc::vec::Vec<T> as core::iter::traits::collect::FromIterator<T>>::from_iter
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/alloc/src/vec/mod.rs:2552:9
    15: core::iter::traits::iterator::Iterator::collect
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/iter/traits/iterator.rs:1784:9
    16: i_slint_compiler::generator::rust::generate_sub_component
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/6622f33/internal/compiler/generator/rust.rs:530:32
    17: i_slint_compiler::generator::rust::generate_item_tree
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/6622f33/internal/compiler/generator/rust.rs:997:20
    18: i_slint_compiler::generator::rust::generate_public_component
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/6622f33/internal/compiler/generator/rust.rs:248:9
    19: i_slint_compiler::generator::rust::generate
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/6622f33/internal/compiler/generator/rust.rs:125:17
    20: slint_build::compile_with_config
               at /home/rdrpenguin/.cargo/git/checkouts/slint-8153123e5dffa129/6622f33/api/rs/build/lib.rs:250:21
    21: build_script_build::main
               at ./build.rs:2:5
    22: core::ops::function::FnOnce::call_once
               at /rustc/1d9c262eea411ec5230f8a4c9ba50b3647064da4/library/core/src/ops/function.rs:227:5

Let me know if there's any way I can help debugging! Sorry again that I couldn't minimize the example code; I'm about out of time for the day.

@hunger
Copy link
Member

hunger commented Mar 30, 2022

Can I have you as a replacement for the fuzzer I run sometimes? That keeps turning up empty handed before I run out of patience and kill it :-)

@ogoffart ogoffart self-assigned this Mar 30, 2022
@ogoffart ogoffart added bug Something isn't working a:compiler Slint compiler internal (not the codegen, not the parser) labels Mar 30, 2022
ogoffart added a commit that referenced this issue Mar 30, 2022
 * The LLR expect that the popup_window is actually contained in it's parent
   component popup_windows, otherwise the context is not correct.
 * There is no index property for a PopupWindow

Fixes #1113
ogoffart added a commit that referenced this issue Mar 30, 2022
 * The LLR expect that the popup_window is actually contained in it's parent
   component popup_windows, otherwise the context is not correct.
 * There is no index property for a PopupWindow

Fixes #1113
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.

3 participants