allow any integer type as index in an element access expression, fixes bug
authorJürg Billeter <j@bitron.ch>
Mon, 30 Apr 2007 09:45:42 +0000 (09:45 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Mon, 30 Apr 2007 09:45:42 +0000 (09:45 +0000)
2007-04-30  Jürg Billeter  <j@bitron.ch>

* vala/valasemanticanalyzer.vala: allow any integer type as index in an
  element access expression, fixes bug 434506

svn path=/trunk/; revision=293

vala/ChangeLog
vala/vala/valasemanticanalyzer.vala

index c7971b5..7d7f3f6 100644 (file)
@@ -1,5 +1,10 @@
 2007-04-30  Jürg Billeter  <j@bitron.ch>
 
+       * vala/valasemanticanalyzer.vala: allow any integer type as index in an
+         element access expression, fixes bug 434506
+
+2007-04-30  Jürg Billeter  <j@bitron.ch>
+
        * vala/parser.y, vala/valasymbolbuilder.vala,
          vala/valaattributeprocessor.vala, vala/valasemanticanalyzer.vala,
          vala/valacodegenerator.vala, vala/valainterfacewriter.vala,
index 39e5582..6cf9cf5 100644 (file)
@@ -868,9 +868,9 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                                if (e.static_type == null) {
                                        /* return on previous error */
                                        return;
-                               } else if (e.static_type.data_type != int_type.data_type) {
+                               } else if (!(e.static_type.data_type is Struct) || !((Struct) e.static_type.data_type).is_integer_type ()) {
                                        expr.error = true;
-                                       Report.error (e.source_reference, "Expected expression of type ´int'");
+                                       Report.error (e.source_reference, "Expression of integer type expected");
                                }
                        }
                        
@@ -1392,9 +1392,9 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
                        }
                        
                        /* check if the index is of type integer */
-                       if (e.static_type.data_type != int_type.data_type && e.static_type.data_type != uint_type.data_type) {
+                       if (!(e.static_type.data_type is Struct) || !((Struct) e.static_type.data_type).is_integer_type ()) {
                                expr.error = true;
-                               Report.error (e.source_reference, "Expression of type `int' or `uint` expected");
+                               Report.error (e.source_reference, "Expression of integer type expected");
                        }
                }
        }