Check type of 'default' initializers in semantic analyzer, fixes bug
authorJared Moore <jaredm@gmx.com>
Sat, 27 Sep 2008 01:53:22 +0000 (01:53 +0000)
committerJared William Moore <jaredm@src.gnome.org>
Sat, 27 Sep 2008 01:53:22 +0000 (01:53 +0000)
2008-08-27  Jared Moore  <jaredm@gmx.com>

* vala/valasemanticanalyser.vala:

Check type of 'default' initializers in semantic analyzer, fixes bug
544556.

svn path=/trunk/; revision=1791

ChangeLog
vala/valasemanticanalyzer.vala

index 0fd2c54..6c13a8d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-08-27  Jared Moore  <jaredm@gmx.com>
+
+       * vala/valasemanticanalyser.vala:
+
+       Check type of 'default' initializers in semantic analyzer, fixes bug
+       544556.
+
 2008-09-26  Jürg Billeter  <j@bitron.ch>
 
        * vapi/glib-2.0.vapi:
index 3473a19..e87facf 100644 (file)
@@ -676,6 +676,11 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                                Report.error (prop.source_reference, "%s: construct properties must be public".printf (prop.get_full_name ()));
                        }
                }
+
+               if (prop.default_expression != null && !(prop.default_expression.value_type.compatible (prop.property_type))) {
+                       prop.error = true;
+                       Report.error (prop.default_expression.source_reference, "Expected initializer of type `%s' but got `%s'".printf (prop.property_type.to_string (), prop.default_expression.value_type.to_string ()));
+               }
        }
 
        public override void visit_property_accessor (PropertyAccessor acc) {