]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Consider boolean types are compatible with each other 792e9672a07fec8cbe4152789ad38c4304c8e266
authorRico Tzschichholz <ricotz@ubuntu.com>
Wed, 1 Apr 2020 12:02:55 +0000 (14:02 +0200)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 1 Apr 2020 12:05:27 +0000 (14:05 +0200)
tests/Makefile.am
tests/basic-types/boolean.vala [new file with mode: 0644]
tests/basic-types/custom-types.vala
vala/valadatatype.vala

index a77e4dbaed9b004210df966e9c807f023088fbed..9f956d793ab5d089b4af2c991c74d66192e0c076 100644 (file)
@@ -24,6 +24,7 @@ TESTS = \
        basic-types/integers.vala \
        basic-types/escape-chars.vala \
        basic-types/floats.vala \
+       basic-types/boolean.vala \
        basic-types/custom-types.vala \
        basic-types/default-gtype.vala \
        basic-types/strings.vala \
diff --git a/tests/basic-types/boolean.vala b/tests/basic-types/boolean.vala
new file mode 100644 (file)
index 0000000..1e6c04f
--- /dev/null
@@ -0,0 +1,20 @@
+[SimpleType]
+[BooleanType]
+public struct Foo {
+       public void check () {
+               if (this) {
+                       return;
+               }
+               assert (true);
+       }
+}
+
+void main () {
+       Foo foo = true;
+
+       foo.check ();
+
+       if (!foo) {
+               assert (true);
+       }
+}
index d979a9beb1a9cbb99155d6ec1a42c2f96e109d05..e8aa5d727928b3f7ce5107495df82f6d66095f39 100644 (file)
@@ -46,6 +46,7 @@ void main () {
                assert (baz == double.MAX);
        }
        {
-               manam_t manam;
+               manam_t manam = true;
+               assert (manam);
        }
 }
index 7dd0e8dcba91fe7d32fec855a3ea14b2dcf89ffa..37d04a1edb970013df3c9c4e9de7789962153449 100644 (file)
@@ -366,6 +366,10 @@ public abstract class Vala.DataType : CodeNode {
                                }
                        }
 
+                       if (expr_struct.is_boolean_type () && expect_struct.is_boolean_type ()) {
+                               return true;
+                       }
+
                        // Allow compatiblity of struct subtypes in both ways
                        if (expect_struct.is_subtype_of (expr_struct)) {
                                return true;