Commit 61d372c3 authored by Simon Werbeck's avatar Simon Werbeck Committed by Luca Bruno

Fix comparison of nullable value types

Fixes bug 678791
parent 3f777384
......@@ -34,6 +34,7 @@ TESTS = \
basic-types/bug652380.vala \
basic-types/bug655908.vala \
basic-types/bug659975.vala \
basic-types/bug678791.vala \
basic-types/bug686336.vala \
namespaces.vala \
methods/lambda.vala \
......
public enum Foo {
BAR
}
void main () {
int? a = null;
int b = 1;
assert (a != b);
assert (b != a);
Foo? f = null;
Foo g = Foo.BAR;
assert (f != g);
assert (g != f);
}
......@@ -422,12 +422,12 @@ public class Vala.BinaryExpression : Expression {
right.target_type.value_owned = false;
if (left.value_type.nullable != right.value_type.nullable) {
// if only one operand is nullable, make sure the other operand is promoted to nullable as well
if (!left.value_type.nullable) {
left.target_type.nullable = true;
} else if (!right.value_type.nullable) {
right.target_type.nullable = true;
}
// if only one operand is nullable, make sure the other
// operand is promoted to nullable as well,
// reassign both, as get_arithmetic_result_type doesn't
// take nullability into account
left.target_type.nullable = true;
right.target_type.nullable = true;
}
value_type = context.analyzer.bool_type;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment