From: Luca Bruno Date: Sun, 24 Jul 2011 07:53:55 +0000 (+0200) Subject: Report an error on element access with wrong number of indices X-Git-Tag: 0.13.2~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f9a5c8ed60ed319bcc79285fd137cd0d2f449cb6;p=thirdparty%2Fvala.git Report an error on element access with wrong number of indices --- diff --git a/vala/valaelementaccess.vala b/vala/valaelementaccess.vala index c81f3b30d..684d6e0c6 100644 --- a/vala/valaelementaccess.vala +++ b/vala/valaelementaccess.vala @@ -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) {