[vala] Support postfix operator on array members
- From: Jürg Billeter <juergbi src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [vala] Support postfix operator on array members
- Date: Tue, 29 Sep 2009 20:20:10 +0000 (UTC)
commit 99ec168d1042c9baa38819805edaadfda2646cd2
Author: Jürg Billeter <j bitron ch>
Date: Tue Sep 29 22:19:18 2009 +0200
Support postfix operator on array members
Fixes bug 596637.
tests/Makefile.am | 1 +
tests/basic-types/bug596637.vala | 5 +++++
vala/valapostfixexpression.vala | 9 ++++++++-
3 files changed, 14 insertions(+), 1 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f1058b8..821b4a2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -20,6 +20,7 @@ TESTS = \
basic-types/strings.vala \
basic-types/arrays.vala \
basic-types/pointers.vala \
+ basic-types/bug596637.vala \
namespaces.vala \
methods/lambda.vala \
methods/closures.vala \
diff --git a/tests/basic-types/bug596637.vala b/tests/basic-types/bug596637.vala
new file mode 100644
index 0000000..904de17
--- /dev/null
+++ b/tests/basic-types/bug596637.vala
@@ -0,0 +1,5 @@
+void main () {
+ int[] a = new int[1];
+ a[0]++;
+ assert (a[0] == 1);
+}
diff --git a/vala/valapostfixexpression.vala b/vala/valapostfixexpression.vala
index 1ed72e1..b9d6af1 100644
--- a/vala/valapostfixexpression.vala
+++ b/vala/valapostfixexpression.vala
@@ -74,7 +74,7 @@ public class Vala.PostfixExpression : Expression {
return false;
}
- if (inner.value_type == null) {
+ if (!(inner.value_type is IntegerType) && !(inner.value_type is FloatingType) && !(inner.value_type is PointerType)) {
error = true;
Report.error (source_reference, "unsupported lvalue in postfix expression");
return false;
@@ -94,6 +94,13 @@ public class Vala.PostfixExpression : Expression {
/* if no symbol found, skip this check */
return false;
}
+ } else if (inner is ElementAccess) {
+ var ea = (ElementAccess) inner;
+ if (!(ea.container.value_type is ArrayType)) {
+ error = true;
+ Report.error (source_reference, "unsupported lvalue in postfix expression");
+ return false;
+ }
} else {
error = true;
Report.error (source_reference, "unsupported lvalue in postfix expression");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]