[vala] Report an error on element access with wrong number of indices
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] Report an error on element access with wrong number of indices
- Date: Sun, 24 Jul 2011 07:54:28 +0000 (UTC)
commit f9a5c8ed60ed319bcc79285fd137cd0d2f449cb6
Author: Luca Bruno <lucabru src gnome org>
Date: Sun Jul 24 09:53:55 2011 +0200
Report an error on element access with wrong number of indices
vala/valaelementaccess.vala | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
---
diff --git a/vala/valaelementaccess.vala b/vala/valaelementaccess.vala
index c81f3b3..684d6e0 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) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]