summaryrefslogtreecommitdiff
path: root/vala/valabinaryexpression.vala
diff options
context:
space:
mode:
authorLuca Bruno <lucabru@src.gnome.org>2014-01-26 18:06:43 +0100
committerLuca Bruno <lucabru@src.gnome.org>2014-01-26 18:06:43 +0100
commit517d25a5daf7016b6af85173af184eb7e6b5e9c4 (patch)
tree44ea8fc9516f291429d2542b0ba8b878dc4e4872 /vala/valabinaryexpression.vala
parent3f68a952ca96fb80ce5ef071e6a5788c8cac068f (diff)
downloadvala-517d25a5daf7016b6af85173af184eb7e6b5e9c4.tar.gz
Fix regression when coalescing: value owned if either of the two is owned
Diffstat (limited to 'vala/valabinaryexpression.vala')
-rw-r--r--vala/valabinaryexpression.vala20
1 files changed, 18 insertions, 2 deletions
diff --git a/vala/valabinaryexpression.vala b/vala/valabinaryexpression.vala
index 9c1ef4c98..bdd9e5eb2 100644
--- a/vala/valabinaryexpression.vala
+++ b/vala/valabinaryexpression.vala
@@ -198,8 +198,24 @@ public class Vala.BinaryExpression : Expression {
error = true;
return false;
}
-
- var local = new LocalVariable (left.value_type != null ? left.value_type.copy () : null, get_temp_name (), left, source_reference);
+
+ if (!right.check (context)) {
+ error = true;
+ return false;
+ }
+
+ DataType local_type = null;
+ if (left.value_type != null) {
+ local_type = left.value_type.copy ();
+ if (right.value_type != null && right.value_type.value_owned) {
+ // value owned if either left or right is owned
+ local_type.value_owned = true;
+ }
+ } else if (right.value_type != null) {
+ local_type = right.value_type.copy ();
+ }
+
+ var local = new LocalVariable (local_type, get_temp_name (), left, source_reference);
var decl = new DeclarationStatement (local, source_reference);
var right_stmt = new ExpressionStatement (new Assignment (new MemberAccess.simple (local.name, right.source_reference), right, AssignmentOperator.SIMPLE, right.source_reference), right.source_reference);