slint/sixtyfps_compiler
Simon Hausmann 03bef6dba3 Fix casting with conditional expressions
The following scenario would fail compiling to C++ because we failed to
determine the return type of the conditional expression:

    Test := Rectangle {
        property<bool> condition;
        property<color> extra_color;
        color: condition ? root.extra_color : 4289374890;
    }

The type of the true branch would be color and the false branch would be
a float. Since they "disagree", ty() on the expression would return
Type::Invalid. This was temporarily worked around in the C++ generator
by always returning the type of the true branch, but that's wrong.

Instead this patch changes maybe_convert_to to apply the Cast expression
to the individual branches, placing the cast only to the numberic
literal and correcting the return value of ty() on the conditional
expression.
2020-06-11 13:38:24 +02:00
..
generator Fix casting with conditional expressions 2020-06-11 13:38:24 +02:00
parser Add support for parsing conditional expression syntax 2020-06-10 15:40:27 +02:00
parser_test_macro Make the Parser a trait 2020-05-22 15:31:27 +02:00
passes Fix casting with conditional expressions 2020-06-11 13:38:24 +02:00
tests Grid layout in the interpreter 2020-06-10 19:40:47 +02:00
Cargo.toml Move the rust generator to the compiler lib 2020-06-05 10:54:22 +02:00
diagnostics.rs Rust macro: get the right span for the diagnostics 2020-05-27 18:37:45 +02:00
expression_tree.rs Fix casting with conditional expressions 2020-06-11 13:38:24 +02:00
generator.rs Move the rust generator to the compiler lib 2020-06-05 10:54:22 +02:00
layout.rs Layout for rust 2020-06-10 19:41:24 +02:00
lib.rs Grid layout in the interpreter 2020-06-10 19:40:47 +02:00
object_tree.rs Grid layout in the interpreter 2020-06-10 19:40:47 +02:00
parser.rs Add support for parsing conditional expression syntax 2020-06-10 15:40:27 +02:00
typeregister.rs Prepare for the ability to embed image data 2020-06-09 22:54:29 +02:00