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

Warn on statements that have no effect #4954

Open
ogoffart opened this issue Mar 27, 2024 · 1 comment
Open

Warn on statements that have no effect #4954

ogoffart opened this issue Mar 27, 2024 · 1 comment
Labels
a:language-slint Compiler for the .slint language (mO,bF) diagnostics Suggestions for better diagnostics

Comments

@ogoffart
Copy link
Member

As discussed in #4942, this Slint code

    FocusScope {
        key-pressed(event) => {
            if (event.text == "a") {
                accept
            }
            reject
        }
    }

Looks like it would return accept, but in fact, the statement has no effect and one should get a warning for that.

And statements with no effect could also be removed, as they may still cause warnings in the generated code.

@ogoffart ogoffart added diagnostics Suggestions for better diagnostics a:language-slint Compiler for the .slint language (mO,bF) labels Mar 27, 2024
@ogoffart
Copy link
Member Author

Removing useless statements would hopefully fix the test

FIXME: The C++ test currently fails with this warning
(see also https://github.com/slint-ui/slint/issues/4954)
//ignore: cpp
(This is the warning, for reference)
statement has no effect [-Werror=unused-value]
| return [&]{ [&]() -> void { if (arg_0) { 45; } else { ; }}();return 12; }();
| ^~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:language-slint Compiler for the .slint language (mO,bF) diagnostics Suggestions for better diagnostics
Projects
None yet
Development

No branches or pull requests

1 participant