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

Calling a method that takes a closure containing a list or number (and maybe others) constant throws a weird exception

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6-rc-1, 1.6-rc-2
    • 1.6.1, 1.7-beta-1
    • None
    • None

    Description

      This script:

      for(myVal in evaluate('[10,11,12]', 2, 'foo') { [10,11,12] }) { 
       println myVal
      }
      
      def evaluate(text, num, thing, closure) {
         closure.call()
      }
      

      Produces:

      Exception thrown: $const$1
      
      java.lang.NoSuchFieldError: $const$1
             at ConsoleScript1$_run_closure1.doCall(ConsoleScript1:1)
             at ConsoleScript1$_run_closure1.doCall(ConsoleScript1)
             at ConsoleScript1.evaluate(ConsoleScript1:6)
             at ConsoleScript1$evaluate.callCurrent(Unknown Source)
      

      Whilst this one that has a String inside the closure works fine:

      for(myVal in evaluate('[10,11,12]', 2, 'foo') { "one" }) { 
       println myVal
      }
      
      def evaluate(text, num, thing, closure) {
         closure.call()
      }
      

      Attachments

        1. Patch.txt
          1.0 kB
          Roshan Dawrani

        Issue Links

          Activity

            People

              roshandawrani Roshan Dawrani
              graemerocher Graeme Rocher
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: