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

panicked at 'invalid expression while evaluating' #2483

Closed
jturcotte opened this issue Apr 4, 2023 · 3 comments · Fixed by #2552
Closed

panicked at 'invalid expression while evaluating' #2483

jturcotte opened this issue Apr 4, 2023 · 3 comments · Fixed by #2552
Assignees
Labels
bug Something isn't working

Comments

@jturcotte
Copy link
Contributor

export Test := VerticalLayout {
    spacing: 1px;

    HorizontalLayout {
        Rectangle {
            // At first I didn't see that there was an HorizontalLayout in-between in the original code.
            width: parent.height - parent.spacing;
        }
    }
}

This is with slint-viewer/slint-lsp 0.3.5, I tried it in the 1.0 SlintPad and it seems to panic there as well.

@tronical tronical added the bug Something isn't working label Apr 5, 2023
@tronical
Copy link
Member

tronical commented Apr 5, 2023

AFAICS it's the parent.spacing that somehow turns into a Expression::Invalid and in the phase lowering to the LLR that panics (since Invalid is kind of hard to lower ;-)

When lowering the binding for width:

        tree_Expression::BinaryExpression { lhs, rhs, op } => llr_Expression::BinaryExpression {
            lhs: Box::new(lower_expression(lhs, ctx)),
            rhs: Box::new(lower_expression(rhs, ctx)), <-- rhs is Expression::Invalid
            op: *op,
        },

@ogoffart
Copy link
Member

ogoffart commented Apr 5, 2023

The viewer and LSP don't lower to LLR, this is probably in the eval phase of the interpreter. But if the LLR makes invalid code, this probably fails for the same reason.

@tronical
Copy link
Member

tronical commented Apr 5, 2023

Yes, the above is with slint-compiler, but with the interpreter it's exactly the same:

        Expression::BinaryExpression { lhs, rhs, op } => {
            let lhs = eval_expression(&**lhs, local_context);
            let rhs = eval_expression(&**rhs, local_context); <-- rhs is invalid

@ogoffart ogoffart self-assigned this Apr 14, 2023
ogoffart added a commit that referenced this issue Apr 14, 2023
The previous code was only re-creating the layout properties for these
that had a binding, but that wasn't done if the property was just read,
leading to access to non-existing properties later.

Fixes #2483
ogoffart added a commit that referenced this issue Apr 14, 2023
The previous code was only re-creating the layout properties for these
that had a binding, but that wasn't done if the property was just read,
leading to access to non-existing properties later.

Fixes #2483
ogoffart added a commit that referenced this issue Apr 14, 2023
The previous code was only re-creating the layout properties for these
that had a binding, but that wasn't done if the property was just read,
leading to access to non-existing properties later.

Fixes #2483
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants