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

for loop scope is bogus

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0-JSR-4
    • 1.0-JSR-5
    • None
    • None
    • Ubuntu Linux, 1.0-JSR-4, on JDK 1.5.0

    Description

      Groovy apparently tries to guess whether you're going to use a loop variable after a for loop ends. There is a bug in the case that you have another for loop that tries to use the same loop variable later. For instance:

      for (i in 0..7) {
      }
      println i
      for (i in 0..7) {
      }

      Groovy produces

      loop.groovy: 4: The current scope does already contain a variable of the name i
      @ line 4, column 1.
      for (i in 0..7) {
      ^

      1 Error

      If the println i is commented out, the program runs.

      Attachments

        Activity

          People

            blackdrag Jochen Theodorou
            riedl John Riedl
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: