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

Error should be produced for callback with multiple aliases #3966

Open ogoffart opened 12 months ago

ogoffart commented 12 months ago

Discussed in https://github.com/slint-ui/slint/discussions/3947#discussioncomment-7597955

export component Foo {
    callback clickedA <=> button.clicked;
    callback clickedB <=> button.clicked;
    button := Button {
        text: "OK!";
    }
}

Multiple callback to the same callback won't work and only one will be run

SlintPad

This should produce an error.

Also happens with Globals.

tronical commented 5 months ago

Similarly, this causes a panic in the compiler:

global Glob {
    callback global-callback();
}

component Foo {
    callback cb <=> Glob.global-callback;
}

export component Demo {
    Foo {
        cb => {
            debug("ok");
        }
    }

    TouchArea {
        clicked => {
            Glob.global-callback();
        }
    }
}
thread 'main' panicked at internal/compiler/llr/optim_passes/count_property_use.rs:55:22:
internal error: entered unreachable code