]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
vala: Fix ownership inheritance of "unowned var" in foreach statement
authorRico Tzschichholz <ricotz@ubuntu.com>
Sat, 6 Mar 2021 08:46:32 +0000 (09:46 +0100)
committerRico Tzschichholz <ricotz@ubuntu.com>
Sat, 13 Mar 2021 20:23:51 +0000 (21:23 +0100)
vala/valaforeachstatement.vala

index 465c817bd651475dda2dd84fbe059e53279ca7ca..d6ef7c2df2f99422455a8e222344f2191f03e382 100644 (file)
@@ -332,9 +332,10 @@ public class Vala.ForeachStatement : Block {
                // analyze element type
                if (type_reference is VarType) {
                        // var type
+                       bool value_owned = type_reference.value_owned;
                        type_reference = element_type.copy ();
                        // FIXME Only follows "unowned var" otherwise inherit ownership of element-type
-                       if (!type_reference.value_owned) {
+                       if (!value_owned) {
                                type_reference.value_owned = false;
                        }
                } else if (!element_type.compatible (type_reference)) {
@@ -354,9 +355,10 @@ public class Vala.ForeachStatement : Block {
                // analyze element type
                if (type_reference is VarType) {
                        // var type
+                       bool value_owned = type_reference.value_owned;
                        type_reference = element_type.copy ();
                        // FIXME Only follows "unowned var" otherwise inherit ownership of element-type
-                       if (!type_reference.value_owned) {
+                       if (!value_owned) {
                                type_reference.value_owned = false;
                        }
                } else if (!element_type.compatible (type_reference)) {