summaryrefslogtreecommitdiff
path: root/vala/valaforeachstatement.vala
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2021-03-06 09:46:32 +0100
committerRico Tzschichholz <ricotz@ubuntu.com>2021-03-06 10:05:31 +0100
commite7b08a38dac95bd74c79a6e579edae1004e0bef7 (patch)
tree4183625b7dbfb4d101d0d2885e6aabef74901995 /vala/valaforeachstatement.vala
parent328faa8e402b8f4b6abbc7099929c3e1442336b2 (diff)
downloadvala-e7b08a38dac95bd74c79a6e579edae1004e0bef7.tar.gz
vala: Fix ownership inheritance of "unowned var" in foreach statement
Diffstat (limited to 'vala/valaforeachstatement.vala')
-rw-r--r--vala/valaforeachstatement.vala6
1 files changed, 4 insertions, 2 deletions
diff --git a/vala/valaforeachstatement.vala b/vala/valaforeachstatement.vala
index 7f77cdc33..bea6c4e93 100644
--- a/vala/valaforeachstatement.vala
+++ b/vala/valaforeachstatement.vala
@@ -336,9 +336,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)) {
@@ -358,9 +359,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)) {