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

VerifyError (InconsistentStackHeight) on assignment to external variable from a scope nested inside a closure

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 1.0-beta-5
    • 1.0-beta-5
    • class generator
    • None
    • JDK 1.4 and 1.5

    Description

      Running the attached script dies with with the following stack trace. It works if I remove "f.eachLine()" and the following closure...

      Exception in thread "main" java.lang.VerifyError: (class: perry$3, method: doCal
      l signature: (Ljava/lang/Object;)Ljava/lang/Object Inconsistent stack height 1
      != 0
      at perry.run(perry.groovy:12)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      [snip]


      Cédric
      http://beust.com/weblog

      import java.io.File
      import java.util.regex.*

      dir = new File("d:/public_html/cedric/perry/endless-armada")
      out = new File("d:/t/endless-armada")

      for (i in 1100..1103) {
      print "${i} =====\n"
      n = 2
      prev = true
      f = new File(dir, "${i}.html")
      f.eachLine { line |
      newLine = ""
      p = Pattern.compile("11@")
      m = p.matcher(line)
      if (line =~ "11@") {
      if (prev)

      { newLine = m.replaceAll(new Integer(i - 1).toString()) }

      else

      { newLine = m.replaceAll(new Integer(i + 1).toString()) }

      prev = ! prev
      print newLine + "\n"
      }
      }
      }

      Attachments

        1. bug343.groovy
          0.0 kB
          Jim Greer
        2. bug343.err
          3 kB
          Jim Greer

        Issue Links

          Activity

            People

              jstrachan James Strachan
              cbeust Cedric Beust
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: