[vala] Add ownership-checks for field initializers
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Add ownership-checks for field initializers
- Date: Wed, 1 Oct 2014 20:45:55 +0000 (UTC)
commit 6f04662e777f88bde419187067631aeacb271d00
Author: Florian Brosch <flo brosch gmail com>
Date: Thu Sep 18 02:53:29 2014 +0200
Add ownership-checks for field initializers
vala/valafield.vala | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/vala/valafield.vala b/vala/valafield.vala
index e6429a1..5eb84de 100644
--- a/vala/valafield.vala
+++ b/vala/valafield.vala
@@ -143,6 +143,16 @@ public class Vala.Field : Variable, Lockable {
return false;
}
+ if (initializer.value_type.is_disposable ()) {
+ /* rhs transfers ownership of the expression */
+ if (!(variable_type is PointerType) && !variable_type.value_owned) {
+ /* lhs doesn't own the value */
+ error = true;
+ Report.error (source_reference, "Invalid assignment from owned
expression to unowned variable");
+ return false;
+ }
+ }
+
if (parent_symbol is Namespace && !initializer.is_constant ()) {
error = true;
Report.error (source_reference, "Non-constant field initializerS not
supported in this context");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]