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.53k stars 600 forks source link

language server crash and slint rust crash on setting ScrollView viewport-width to child width #6237

Open rscarson opened 1 month ago

rscarson commented 1 month ago

This crashes both the language server and the actual software I am writing

        ScrollView {
            width: 100%;
            viewport-width: v.width; // Source of the error

            v:= VerticalBox {
                [...]

Error dump was a long set of these

[Error - 1:48:19 PM] Request textDocument/documentSymbol failed.
Error: selectionRange must be contained in fullRange
    at Function.validate (c:\Users\username\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:159:18755)
    at new h (c:\Users\username\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:159:18969)
    at asDocumentSymbol (c:\Users\username\.vscode\extensions\slint.slint-1.7.2\node_modules\vscode-languageclient\lib\common\protocolConverter.js:604:22)
    at asDocumentSymbol (c:\Users\username\.vscode\extensions\slint.slint-1.7.2\node_modules\vscode-languageclient\lib\common\protocolConverter.js:609:31)
    at convertBatch (c:\Users\username\.vscode\extensions\slint.slint-1.7.2\node_modules\vscode-languageclient\lib\common\utils\async.js:193:25)
    at Object.map (c:\Users\username\.vscode\extensions\slint.slint-1.7.2\node_modules\vscode-languageclient\lib\common\utils\async.js:202:17)
    at Object.asDocumentSymbols (c:\Users\username\.vscode\extensions\slint.slint-1.7.2\node_modules\vscode-languageclient\lib\common\protocolConverter.js:601:22)
    at _provideDocumentSymbols (c:\Users\username\.vscode\extensions\slint.slint-1.7.2\node_modules\vscode-languageclient\lib\common\documentSymbol.js:83:76)
    at h.provideDocumentSymbols (c:\Users\username\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:161:103267)
Error loading SVG from C:\Users\username\Repositories\calian_workspace\zoneapp\ui\assets\icons\arrow-down.svg: The system cannot find the file specified. (os error 2)
Could not load image AbsolutePath("C:\\Users\\username\\Repositories\\calian_workspace\\zoneapp\\ui\\assets\\icons\\arrow-down.svg")
Error loading SVG from C:\Users\username\Repositories\calian_workspace\zoneapp\ui\assets\icons\arrow-down.svg: The system cannot find the file specified. (os error 2)
Could not load image AbsolutePath("C:\\Users\\username\\Repositories\\calian_workspace\\zoneapp\\ui\\assets\\icons\\arrow-down.svg")
thread 'main' panicked at D:\a\slint\slint\internal\core\properties.rs:523:9:
Recursion detected
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[Info  - 8:06:07 PM] Connection to server got closed. Server will restart.
true
The Slint Language Server crashed. This is a bug. Please open an issue on https://github.com/slint-ui/slint/issues
ogoffart commented 1 month ago

Thanks, i can reproduce:

import {  ScrollView } from "std-widgets.slint";
export component Example {
    ScrollView {
        viewport-width: v.width;
         v := VerticalLayout {
        }
    }
}

There is a binding loop but the compiler don't see it.

Edit: even more self-contained:

component ScrollView {
    in-out property <length> viewport-width <=> flickable.viewport-width;
    flickable := Flickable {
        @children
    }
}

export component Demo {
    ScrollView {
        viewport-width: v.width;
        v := VerticalLayout {   }
    }
}
ogoffart commented 1 month ago

The Flickable itself create a two way binding between the flickable.viewport-width and the internal's viewport.width property.

Maybe similar to https://github.com/slint-ui/slint/issues/417