]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Support XOR operation for booleans
authorLuca Bruno <lucabru@src.gnome.org>
Fri, 5 Dec 2014 18:00:51 +0000 (19:00 +0100)
committerLuca Bruno <lucabru@src.gnome.org>
Fri, 5 Dec 2014 18:00:51 +0000 (19:00 +0100)
Fixes bug 729907

tests/Makefile.am
tests/basic-types/bug729907.vala [new file with mode: 0644]
vala/valabinaryexpression.vala

index ee5bbfeab8616e4beb76def2e7b174021449c7d4..8143bda83f85d8ae7917e8799ab13d6baeac7aa9 100644 (file)
@@ -37,6 +37,7 @@ TESTS = \
        basic-types/bug659975.vala \
        basic-types/bug678791.vala \
        basic-types/bug686336.vala \
+       basic-types/bug729907.vala \
        namespaces.vala \
        methods/lambda.vala \
        methods/closures.vala \
diff --git a/tests/basic-types/bug729907.vala b/tests/basic-types/bug729907.vala
new file mode 100644 (file)
index 0000000..fbbebb2
--- /dev/null
@@ -0,0 +1,5 @@
+void main () {
+       assert (false ^ true == true);
+       assert (true ^ true == false);
+       assert (false ^ false == false);
+}
\ No newline at end of file
index 8ccddba0d729efc32edc71cacce8eddafb8351d2..0c9bf32431a1e1ec8dd1b0a61a1ff168e15225a3 100644 (file)
@@ -355,8 +355,7 @@ public class Vala.BinaryExpression : Expression {
                        }
                } else if (operator == BinaryOperator.MOD
                           || operator == BinaryOperator.SHIFT_LEFT
-                          || operator == BinaryOperator.SHIFT_RIGHT
-                          || operator == BinaryOperator.BITWISE_XOR) {
+                          || operator == BinaryOperator.SHIFT_RIGHT) {
                        left.target_type.nullable = false;
                        right.target_type.nullable = false;
 
@@ -433,7 +432,8 @@ public class Vala.BinaryExpression : Expression {
 
                        value_type = context.analyzer.bool_type;
                } else if (operator == BinaryOperator.BITWISE_AND
-                          || operator == BinaryOperator.BITWISE_OR) {
+                          || operator == BinaryOperator.BITWISE_OR
+                          || operator == BinaryOperator.BITWISE_XOR) {
                        // integer type or flags type
                        left.target_type.nullable = false;
                        right.target_type.nullable = false;