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

Problem currying null parameters

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.8.0, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.8.5
    • 1.8.6, 2.0-beta-3
    • None
    • None

    Description

      When I apply the spread operator to a List containing a single null and use the result of that as an argument to .curry, an NPE is thrown with 1.8.x but not with 1.7.10.

      script1.groovy
      c = { x ->
          println "X is ${x}"
      }
      
      args = [42]
      
      c = c.curry(*args)
      
      c()
      
      script2.groovy
      c = { x, y ->
          println "X is ${x}"
          println "Y is ${y}"
      }
      
      args = [42, 2112]
      
      c = c.curry(*args)
      
      c()
      
      script3.groovy
      c = { x, y ->
          println "X is ${x}"
          println "Y is ${y}"
      }
      
      args = [null, null]
      
      c = c.curry(*args)
      
      c()
      

      (This next script is the problematic one...)

      script4.groovy
      c = { x ->
          println "X is ${x}"
      }
      
      args = [null]
      
      c = c.curry(*args)
      
      c()
      

      With Groovy 1.7.10:

      curry $ groovy -version
      Groovy Version: 1.7.10 JVM: 1.6.0_29
      curry $ 
      curry $ groovy script1
      X is 42
      curry $ 
      curry $ groovy script2
      X is 42
      Y is 2112
      curry $ 
      curry $ groovy script3
      X is null
      Y is null
      curry $ 
      curry $ groovy script4
      X is null
      curry $
      

      With Groovy 1.8.5:

      curry $ groovy -version
      Groovy Version: 1.8.5 JVM: 1.6.0_29 Vendor: Apple Inc. OS: Mac OS X
      curry $ groovy script1
      X is 42
      curry $ groovy script2
      X is 42
      Y is 2112
      curry $ groovy script3
      X is null
      Y is null
      curry $ groovy script4
      Caught: java.lang.NullPointerException
      java.lang.NullPointerException
      	at script4.run(script4.groovy:7)
      

      Attachments

        Activity

          People

            paulk Paul King
            brownj Jeff Brown
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: