[vala] Support XOR operation for booleans



commit 43162699924ee9295b47e1fecf6068e6fe4b4ad8
Author: Luca Bruno <lucabru src gnome org>
Date:   Fri Dec 5 19:00:51 2014 +0100

    Support XOR operation for booleans
    
    Fixes bug 729907

 tests/Makefile.am                |    1 +
 tests/basic-types/bug729907.vala |    5 +++++
 vala/valabinaryexpression.vala   |    6 +++---
 3 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ee5bbfe..8143bda 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
index 0000000..fbbebb2
--- /dev/null
+++ b/tests/basic-types/bug729907.vala
@@ -0,0 +1,5 @@
+void main () {
+       assert (false ^ true == true);
+       assert (true ^ true == false);
+       assert (false ^ false == false);
+}
\ No newline at end of file
diff --git a/vala/valabinaryexpression.vala b/vala/valabinaryexpression.vala
index 8ccddba..0c9bf32 100644
--- a/vala/valabinaryexpression.vala
+++ b/vala/valabinaryexpression.vala
@@ -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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]