[vala] Forbid non-constant initializers for static fields in compact classes



commit aa52b5be484f0c3d4dfcafe249bdf1c72265c778
Author: Simon Werbeck <simon werbeck gmail com>
Date:   Sun Mar 31 23:39:32 2013 +0200

    Forbid non-constant initializers for static fields in compact classes
    
    Fixes bug 636509

 vala/valafield.vala |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/vala/valafield.vala b/vala/valafield.vala
index 48986cc..e6429a1 100644
--- a/vala/valafield.vala
+++ b/vala/valafield.vala
@@ -149,6 +149,12 @@ public class Vala.Field : Variable, Lockable {
                                return false;
                        }
 
+                       if (binding == MemberBinding.STATIC && parent_symbol is Class && 
((Class)parent_symbol).is_compact && !initializer.is_constant ()) {
+                               error = true;
+                               Report.error (source_reference, "Static fields in compact classes cannot have 
non-constant initializers");
+                               return false;
+                       }
+
                        if (external) {
                                error = true;
                                Report.error (source_reference, "External fields cannot use initializers");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]