]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Report an error on element access with wrong number of indices
authorLuca Bruno <lucabru@src.gnome.org>
Sun, 24 Jul 2011 07:53:55 +0000 (09:53 +0200)
committerLuca Bruno <lucabru@src.gnome.org>
Sun, 24 Jul 2011 07:53:55 +0000 (09:53 +0200)
vala/valaelementaccess.vala

index c81f3b30d04cdbfa812b46f6148eca33ce458bf7..684d6e0c61e630c1e9ccc503e53ef27bb8297108 100644 (file)
@@ -142,6 +142,12 @@ public class Vala.ElementAccess : Expression {
                        if (!lvalue) {
                                value_type.value_owned = false;
                        }
+
+                       if (array_type.rank < get_indices ().size) {
+                               Report.error (source_reference, "%d extra indices for element access".printf (get_indices ().size - array_type.rank));
+                       } else if (array_type.rank > get_indices ().size) {
+                               Report.error (source_reference, "%d missing indices for element access".printf (array_type.rank - get_indices ().size));
+                       }
                } else if (pointer_type != null && !pointer_type.base_type.is_reference_type_or_type_parameter ()) {
                        value_type = pointer_type.base_type.copy ();
                } else if (context.profile == Profile.DOVA && container_type == context.analyzer.tuple_type.data_type) {