]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
Allow invocation of void methods as initializer and iterator in for
authorJuerg Billeter <j@bitron.ch>
Fri, 23 May 2008 08:44:13 +0000 (08:44 +0000)
committerJürg Billeter <juergbi@src.gnome.org>
Fri, 23 May 2008 08:44:13 +0000 (08:44 +0000)
2008-05-23  Juerg Billeter  <j@bitron.ch>

* vala/valasemanticanalyzer.vala:

Allow invocation of void methods as initializer and iterator in
for statements, patch by Jared Moore, fixes bug 514801

* tests/Makefile.am:
* tests/statements-iteration.exp:
* tests/statements-iteration.vala:

Test void methods in for statements

svn path=/trunk/; revision=1405

ChangeLog
tests/Makefile.am
tests/statements-iteration.exp [new file with mode: 0644]
tests/statements-iteration.vala [new file with mode: 0644]
vala/valasemanticanalyzer.vala

index 0136fd008c7cbd592ab1924fa994f734589f955b..0802206783daf6a74fc49e35810dc68826f32852 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2008-05-23  Jürg Billeter  <j@bitron.ch>
+
+       * vala/valasemanticanalyzer.vala:
+
+       Allow invocation of void methods as initializer and iterator in
+       for statements, patch by Jared Moore, fixes bug 514801
+
+       * tests/Makefile.am:
+       * tests/statements-iteration.exp:
+       * tests/statements-iteration.vala:
+
+       Test void methods in for statements
+
 2008-05-22  Jürg Billeter  <j@bitron.ch>
 
        * vapi/Makefile.am:
index bee987bb36232f97d43e6188e72802cf752bbd62..caa962578f41b504d8ca2127e851a1d2d7cef5e3 100644 (file)
@@ -22,6 +22,7 @@ TESTS = \
        expressions-assignments.vala \
        expressions-lambda.vala \
        statements-selection.vala \
+       statements-iteration.vala \
        statements-jump.vala \
        namespaces.vala \
        classes.vala \
@@ -59,6 +60,7 @@ EXTRA_DIST = \
        expressions-assignments.exp \
        expressions-lambda.exp \
        statements-selection.exp \
+       statements-iteration.exp \
        statements-jump.exp \
        namespaces.exp \
        classes.exp \
diff --git a/tests/statements-iteration.exp b/tests/statements-iteration.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/tests/statements-iteration.vala b/tests/statements-iteration.vala
new file mode 100644 (file)
index 0000000..c435c04
--- /dev/null
@@ -0,0 +1,14 @@
+void void_method () {
+}
+
+// http://bugzilla.gnome.org/show_bug.cgi?id=514801
+void test_for_void_methods () {
+       for (void_method (); ; void_method ()) {
+               break;
+       }
+}
+
+void main () {
+       test_for_void_methods ();
+}
+
index a01d26952041c87a2f11d7bc1b79939ecb150ec8..d954c839f6e4e929d0df43a5932a6a70414fda38 100644 (file)
@@ -1827,7 +1827,10 @@ public class Vala.SemanticAnalyzer : CodeVisitor {
 
                if (ret_type is VoidType) {
                        // void return type
-                       if (!(expr.parent_node is ExpressionStatement)) {
+                       if (!(expr.parent_node is ExpressionStatement)
+                           && !(expr.parent_node is ForStatement)) {
+                               // A void method invocation can be in the initializer or
+                               // iterator of a for statement
                                expr.error = true;
                                Report.error (expr.source_reference, "invocation of void method not allowed as expression");
                                return;