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.56k stars 604 forks source link

compiler panic in move_declarations.rs #3916

Closed stolen-programmer closed 11 months ago

stolen-programmer commented 1 year ago
import {StandardTableView} from "std-widgets.slint";

export component Window {
    VerticalLayout {

        filter := TextInput {
            height: 20px;
        }

        v := StandardTableView {
            // width: 230px;
            // height: 200px;
            columns: [
                { title: "Header 1" },
                { title: "Header 2" },
            ];
            rows: [
                [
                    { text: "Item 1" }, { text: "Item 2" },
                ],
                [
                    { text: "Item 1" }, { text: "Item 2" },
                ],
                [
                    { text: "Item 1" }, { text: "Item 2" },
                ]
            ];
        }

    }

}

Starting preview crashes when the component name is Window

Cargo.toml

[package]
name = "manager"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies.tokio]
version = "1.34.0"
features = ["full"]

[dependencies.slint]
version = "1.2.2"

[dependencies.reqwest]
version = "0.11.22"

[build-dependencies]
slint-build = "1.2.2"
$ cargo --version
cargo 1.73.0 (9c4383fb5 2023-08-26)
$ rustc --version
rustc 1.73.0 (cc66ad468 2023-10-03)

Host x86_64 Windows 10

vscode slint plugin

ogoffart commented 1 year ago

Thanks for reporting the bug. Could you provide the panic message? It should be in the "Slint LSP" output tab.

stolen-programmer commented 1 year ago

image

stolen-programmer commented 1 year ago

image

ogoffart commented 1 year ago

Thanks, i can reproduce it. (Note: also with the viewer)

jturcotte commented 12 months ago

I'm getting this panic in slint-lsp since 1.3.0, it worked in 1.2.2 and slint-viewer 1.3.0 also doesn't seem to have the issue.

The timing makes me think it's probably the same issue but I can't figure this out from the stack trace above without symbols. Let me know if this would better go in a new issue.

LSP log:

:: [21:42:52.488] --> slint textDocument/documentHighlight (8): {'position': {'line': 35, 'character': 37}, 'textDocument': {'uri': 'file://~/temp/cooperator/ui/main.slint'}}
:: [21:42:52.492] --> slint textDocument/codeAction (9): {'range': {'start': {'line': 35, 'character': 37}, 'end': {'line': 35, 'character': 37}}, 'context': {'triggerKind': 2, 'diagnostics': []}, 'textDocument': {'uri': 'file://~/temp/cooperator/ui/main.slint'}}
:: [21:42:52.493] <<< slint (8) (duration: 4ms): [{'range': {'start': {'line': 35, 'character': 37}, 'end': {'line': 35, 'character': 44}}}]
:: [21:42:52.498] <<< slint (9) (duration: 6ms): [{'command': 'slint/showPreview', 'title': 'Show Preview', 'arguments': ['file://~/temp/cooperator/ui/main.slint', 'MainWindow']}]
:: [21:42:53.529] --> slint workspace/executeCommand (10): {'workDoneToken': '$ublime-work-done-progress-10', 'command': 'slint/showPreview', 'arguments': ['file://~/temp/cooperator/ui/main.slint', 'MainWindow']}
:: [21:42:53.543] <<< slint (10) (duration: 13ms): None
:: [21:42:53.599] <?  slint experimental/serverStatus: {'health': 'ok', 'quiescent': False, 'message': 'Loading Preview…'}
:: [21:42:53.637] <-  slint textDocument/publishDiagnostics: {'diagnostics': [{'message': "The function 'cycle_step_colum' is private. Annotate it with 'public' to make it accessible from other components. Note: this used to be allowed in previous version, but this should be considered an error", 'severity': 2, 'range': {'start': {'line': 58, 'character': 95}, 'end': {'line': 58, 'character': 95}}}, {'message': "The function 'cycle_step_colum' is private. Annotate it with 'public' to make it accessible from other components. Note: this used to be allowed in previous version, but this should be considered an error", 'severity': 2, 'range': {'start': {'line': 59, 'character': 96}, 'end': {'line': 59, 'character': 96}}}], 'uri': 'file://~/temp/cooperator/ui/common.slint'}
:: [21:42:53.639] <?  slint experimental/serverStatus: {'health': 'ok', 'quiescent': False, 'message': 'Preview Loaded'}
slint: thread 'main' panicked at ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/i-slint-core-1.3.0/properties.rs:486:9:
slint: Recursion detected
slint: stack backtrace:
slint:    0: rust_begin_unwind
slint:              at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:595:5
slint:    1: core::panicking::panic_fmt
slint:              at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:67:14
slint:    2: i_slint_core::properties::Property<T>::get
slint:    3: core::ops::function::FnOnce::call_once
slint:    4: i_slint_core::properties::alloc_binding_holder::evaluate
slint:    5: i_slint_core::properties::Property<T>::get
slint:    6: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerPreviewUi as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::item_geometry
slint:    7: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerPreviewUi as const_field_offset::PinnedDrop>::drop::VT::item_geometry
slint:    8: i_slint_core::item_tree::ItemRc::is_visible
slint:    9: i_slint_core::item_tree::ItemRc::is_visible
slint:   10: i_slint_core::item_tree::ItemRc::is_visible
slint:   11: i_slint_core::item_tree::ItemRc::is_visible
slint:   12: i_slint_core::item_tree::ItemRc::is_visible
slint:   13: i_slint_core::item_tree::ItemRc::is_visible
slint:   14: i_slint_core::window::WindowInner::move_focus
slint:   15: i_slint_core::window::WindowInner::set_focus_item
slint:   16: slint_interpreter::dynamic_item_tree::InstanceRef::access_window
slint:   17: slint_interpreter::eval::call_builtin_function
slint:   18: slint_interpreter::eval::eval_expression
slint:   19: slint_interpreter::dynamic_item_tree::ErasedItemTreeBox::run_setup_code
slint:   20: slint_interpreter::dynamic_item_tree::ItemTreeDescription::create
slint:   21: slint_interpreter::api::ComponentDefinition::create_embedded
slint:   22: slint_lsp::preview::set_preview_factory::{{closure}}
slint:   23: i_slint_core::component_factory::ComponentFactory::new::{{closure}}
slint:   24: i_slint_core::items::component_container::ComponentContainer::ensure_updated
slint:   25: <i_slint_core::items::component_container::ComponentContainer as i_slint_core::items::Item_vtable_mod::Item>::layout_info
slint:   26: core::ops::function::FnOnce::call_once
slint:   27: i_slint_core::properties::alloc_binding_holder::evaluate
slint:   28: i_slint_core::properties::Property<T>::get
slint:   29: core::ops::function::FnOnce::call_once
slint:   30: i_slint_core::properties::alloc_binding_holder::evaluate
slint:   31: i_slint_core::properties::Property<T>::get
slint:   32: core::ops::function::FnOnce::call_once
slint:   33: i_slint_core::properties::alloc_binding_holder::evaluate
slint:   34: i_slint_core::properties::Property<T>::get
slint:   35: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerPreviewUi as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::item_geometry
slint:   36: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerPreviewUi as const_field_offset::PinnedDrop>::drop::VT::item_geometry
slint:   37: i_slint_core::item_tree::ItemRc::geometry
slint:   38: i_slint_core::item_rendering::ItemRenderer::filter_item
slint:   39: i_slint_core::item_tree::<impl i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitor for T>::visit_item
slint:   40: i_slint_core::item_tree::visit_item_tree::{{closure}}
slint:   41: i_slint_core::item_tree::visit_item_tree
slint:   42: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerPreviewUi as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::visit_children_item
slint:   43: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerPreviewUi as const_field_offset::PinnedDrop>::drop::VT::visit_children_item
slint:   44: i_slint_core::item_tree::<impl i_slint_core::item_tree::ItemVisitor_vtable_mod::ItemVisitor for T>::visit_item
slint:   45: i_slint_core::item_tree::visit_item_tree::{{closure}}
slint:   46: i_slint_core::item_tree::visit_item_tree
slint:   47: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerPreviewUi as i_slint_core::item_tree::ItemTree_vtable_mod::ItemTree>::visit_children_item
slint:   48: <slint_lsp::preview::ui::slint_generatedPreviewUi::InnerPreviewUi as const_field_offset::PinnedDrop>::drop::VT::visit_children_item
slint:   49: i_slint_core::item_rendering::render_component_items
slint:   50: i_slint_backend_qt::qt_window::QtWindow::paint_event::{{closure}}
slint:   51: i_slint_core::properties::PropertyTracker<DirtyHandler>::evaluate_as_dependency_root
slint:   52: Slint_paintEvent
slint:   53: _ZN11SlintWidget10paintEventEP11QPaintEvent
slint:   54: _ZN7QWidget5eventEP6QEvent
slint:   55: _ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent
slint:   56: _ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent
slint:   57: _ZN14QWidgetPrivate14sendPaintEventERK7QRegion
slint:   58: _ZN14QWidgetPrivate10drawWidgetEP12QPaintDeviceRK7QRegionRK6QPoint6QFlagsINS_14DrawWidgetFlagEEP8QPainterP21QWidgetRepaintManager
slint:   59: <unknown>
slint:   60: <unknown>
slint:   61: <unknown>
slint:   62: _ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent
slint:   63: _ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent
slint:   64: _ZN22QGuiApplicationPrivate18processExposeEventEPN29QWindowSystemInterfacePrivate11ExposeEventE
slint:   65: _ZN22QWindowSystemInterface22sendWindowSystemEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE
slint:   66: <unknown>
slint:   67: <unknown>
slint:   68: <unknown>
slint:   69: g_main_context_iteration
slint:   70: _ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE
slint:   71: _ZN10QEventLoop4execE6QFlagsINS_17ProcessEventsFlagEE
slint:   72: _ZN16QCoreApplication4execEv
slint:   73: <i_slint_backend_qt::Backend as i_slint_core::platform::Platform>::run_event_loop
slint:   74: i_slint_core::with_platform
slint:   75: slint_lsp::preview::native::start_ui_event_loop
slint:   76: slint_lsp::main
qarmin commented 12 months ago

I have very similar crash to https://github.com/slint-ui/slint/issues/3916#issuecomment-1811266349, But this is quite strange, that crash happens only with lsp and only when I preview certain components. When I preview parent of broken component, then everything works fine

ogoffart commented 12 months ago

@jturcotte , @qarmin : this seems to be a different issue so i opened #3950 . Could you paste examples to reproduce there?

edit: https://github.com/slint-ui/slint/issues/3950

ogoffart commented 11 months ago

export component Window {

The problem is that the Slint compiler is confused because this will override the "builtin" Window. Workaound is to rename that component for now.