Hi OC,

Not answering the parser question but offering up a slightly different approach:


def counter() {
    for ((n, m) = [1,10] ; n<m ; n++){
        println "$n"
    }
}

counter()



Cheers,

Duncan

On Wed, Aug 19, 2015 at 7:00 AM, OC <ocs@ocs.cz> wrote:
Hello there,

is this a parser bug, or am I overlooking something of importance?

===
17 /tmp> <q.groovy
def foo() {
  int n=1,m=2; // allright
  println "$n $m"
}
def bar() {
  for (int n=1,m=2;n<m;n++) println "$n" // oops
}
18 /tmp> groovy q
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/private/tmp/q.groovy: 6: unexpected token: = @ line 6, column 13.
     for (int n=1,m=2;n<m;n++) println "$n" // oops
               ^

1 error

19 /tmp> groovy -v
Groovy Version: 2.3.8 JVM: 1.7.0_13 Vendor: Oracle Corporation OS: Mac OS X
20 /tmp>
===

Note, incidentally, that Java has this right:

===
25 /tmp> <q.java
class q {
  public static void main(String[] args) {
    for (int n=1,m=2;n<m;n++) System.out.println("-> "+n);
  }
}
26 /tmp> javac q.java && java q
-> 1
27 /tmp>
===

Thanks and all the best,
OC