Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-1398

array[0]++ doesn't compile

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.0-JSR-6
    • 1.1-beta-2
    • None
    • None
    • Mac OSX Intel

    Description

      I've been playing a little with running Groovy scripts from within Java. Pretty simple how I am doing this:

      Binding binding=new Binding();
      int[] i=new int[1];
      binding.setVariable("i", i);

      GroovyShell shell=new GroovyShell(getClass().getClassLoader(), binding);
      shell.evaluate("i[0]++");

      Now the strange thing is that a compiler error occurs at i[0]++. I'd expected that it would take the first element of the array and increment it. Apparently I'm wrong. Here's the exception:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, General error during class
      generation: BinaryExpression appeared on LHS. .
      Node: org.codehaus.groovy.ast.expr.BinaryExpression. At [1:2] Script1.groovy

      the script i[0]+=1 works.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            jeichar@refractions.net jeichar@refractions.net
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: