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

Panic in slint compiler: The remove return pass should have removed all return #5430

Closed
npwoods opened this issue Jun 18, 2024 · 2 comments · Fixed by #5431
Closed

Panic in slint compiler: The remove return pass should have removed all return #5430

npwoods opened this issue Jun 18, 2024 · 2 comments · Fixed by #5431
Labels
a:compiler Slint compiler internal (not the codegen, not the parser) bug Something isn't working

Comments

@npwoods
Copy link

npwoods commented Jun 18, 2024

Steps to reproduce:

  1. Open up attached minimal Rust project
  2. cargo build
thread 'main' panicked at C:\<<redacted>>\.cargo\registry\src\index.crates.io-6f17d22bba15001f\i-slint-compiler-.6.0\llr\lower_expression.rs:199:13:
  The remove return pass should have removed all return

bug-demo.zip

@ogoffart
Copy link
Member

ogoffart commented Jun 19, 2024

Thanks for the bug report.
I can reproduce it.

It needs two files to be reproduced:

treeview.slint:

export global MyFluentPalette {
    property <bool> dark-color-scheme: {
        return false;
    }
    out property <brush> control-foreground: dark-color-scheme ? #FFFFFF : #000000E6;
}

main.slint

import { MyFluentPalette } from "treeview.slint";
export component AppWindow inherits Window {
    out property <bool> foo: MyFluentPalette.dark-color-scheme ? true : false;
}

Looks like property of global exported in another file are not properly handled

@ogoffart ogoffart added bug Something isn't working a:compiler Slint compiler internal (not the codegen, not the parser) labels Jun 19, 2024
@ogoffart
Copy link
Member

This happens for global on other files because then the property can be inlined, but it can also be reproduced by one file with a private property

export component AppWindow inherits Window {
    property <bool> xxx: {
        return false;
    }
    out property <string> foo: xxx ? "true" : "false";
}

The problem is that the condition contains a return:
foo: if ({ return false; }) { "true" } else { "false" }
Not only the returned is not removed, but it is wrong to inline returns

The remove return pass needs to be done before const propagation

ogoffart added a commit that referenced this issue Jun 19, 2024
Otherwise we end up inlining "returns" in the wrong property

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

2 participants