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

build panic: not a rvalue #5260

Closed
lifeRobot opened this issue May 17, 2024 · 1 comment · Fixed by #5311
Closed

build panic: not a rvalue #5260

lifeRobot opened this issue May 17, 2024 · 1 comment · Fixed by #5311
Labels
a:compiler Slint compiler internal (not the codegen, not the parser) bug Something isn't working

Comments

@lifeRobot
Copy link

slint version: 1.6.0
rust version: 1.78.0
system: win11

build panic msg

image

slint code
export component DrawerCommon {
    in-out property <bool> show: false;
    in property <brush> background: white;

    callback clicked <=> touch.clicked;

    x: 0;
    y: 0;
    width: 50%;
    height: 50%;

    animate width,height,x,y {
         duration: 300ms;
    }

    @children

    // fix that triggers the click effect of covered layer components
    touch:= TouchArea {}
}

export component DrawerLeft inherits DrawerCommon {
    private property <length> logic_width;
    height: 100%;

    cont:= Rectangle {
        background: root.background;
        clip: true;

        animate width {
             duration: 300ms;
        }

        init => {
            logic_width = root.width;
            change_width();
        }

        @children
    }

    public function open() {
        change_show(true);
    }

    public function close() {
        change_show(false);
    }

    public function toggle() {
        change_show(!root.show);
    }

    public function change_show(show:bool) {
        root.show = show;
        change_width();
    }

    function change_width() {
        if root.show {
            root.width = logic_width;
            cont.width = logic_width;
            return;
        }

        root.width = 0;
        cont.width = 0;
    }
}

export component A { 
    dr:= DrawerLeft {
        width: 100px;
        height: 100px;
        background: red;
        Text {
            text: "hello world";
        }
    }

    public function open() {
        dr.open()
    }
}

export component App inherits Window {
    min-width: 300px;
    min-height: 300px;

    dr:= A {
        x:0;
        y:0;
    }
    /*dr:= DrawerLeft {
        width: 100px;
        height: 100px;
        background: red;
        Text {
            text: "hello world";
        }
    }*/

    init => {
        dr.open()
    }
}
Cargo.toml
slint-build = "1.6.0"
slint = "1.6.0"

other issue

  1. If I use version 1.5.1 of slint, I can compile and run normally, just modify Cargo.toml to the following content
slint-build = "~1.5.1"
slint = "~1.5.1"
  1. If I copy slint code into slintpad, slintpad will no longer have any feedback and will not display error messages
@hunger hunger added bug Something isn't working a:compiler Slint compiler internal (not the codegen, not the parser) labels May 22, 2024
@ogoffart
Copy link
Member

Thanks for the bug report.

I was able to reproduce with a minimal testcase:

export component DrawerLeft {
    private property <length> logic_width;
    rect := Rectangle {
        init => {
            logic_width = root.width;
        }
        @children
    }
}

export component A {
    hello := DrawerLeft { }
}

export component App inherits Window {
    world := A { }
}

From a first investigation, the problem is that the const_propagation::const_propagation pass introduces some Invalid expression in the init code. The init code is referencing property such as root.hello-width while at this point, it should be hello-3-width, so something went wrong in one of the compiler pass that had to move properties around.
I will have to investigate this further.

ogoffart added a commit that referenced this issue May 28, 2024
The `fixup_init_expression` was not called for every instructions when it was inlined,
causing invalid code in further passes

Fixes #5260
ogoffart added a commit that referenced this issue May 28, 2024
The `fixup_init_expression` was not called for every instructions when it was inlined,
causing invalid code in further passes

Fixes #5260
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