]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Check switch expression
authorJürg Billeter <j@bitron.ch>
Mon, 15 Dec 2008 19:59:02 +0000 (19:59 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Mon, 15 Dec 2008 19:59:02 +0000 (19:59 +0000)
2008-12-15  Jürg Billeter  <j@bitron.ch>

* vala/valaswitchstatement.vala:

Check switch expression

svn path=/trunk/; revision=2158

ChangeLog
vala/valaswitchstatement.vala

index 4b6c7ebc723e847ae5c25b1b9c5ca37caf58b8e7..c96f31c2495ef8fbcd3225d7ffd0d714be6662a2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-12-15  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valaswitchstatement.vala:
+
+       Check switch expression
+
 2008-12-15  Jürg Billeter  <j@bitron.ch>
 
        * vapi/glib-2.0.vapi:
index e3c272752044519cb4a9aa93dbcd6d1ef6fe859c..0fd5b838332a0f4cef92df92f8dd71158f121206 100644 (file)
@@ -101,7 +101,17 @@ public class Vala.SwitchStatement : CodeNode, Statement {
 
                checked = true;
 
-               expression.check (analyzer);
+               if (!expression.check (analyzer)) {
+                       error = true;
+                       return false;
+               }
+
+               if (!expression.value_type.compatible (analyzer.uint64_type)
+                   && !expression.value_type.compatible (analyzer.string_type)) {
+                       Report.error (expression.source_reference, "Integer or string expression expected");
+                       error = true;
+                       return false;
+               }
 
                foreach (SwitchSection section in sections) {
                        section.check (analyzer);