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

BUG! exception in phase 'parsing' in source unit 'Script1.groovy' null

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.7.3
    • Fix Version/s: 1.7.4, 1.8-beta-1
    • Component/s: None
    • Labels:
      None

      Description

      I am encountering another parser "bug"

      does not work:

      def params = new Expando()
      params.newValue = 23
      def trendMap = ['worsening': (-2), 'slightly worsening':(-1), 'neutral':0 ,'slightly improving': 1,'improving':2]
      
      def obj = []
      def el = [obj]
      if (!el[1]) el[1] = "1"
      
      Eval.x(el[0],"x[1]="+ el[2] ? trendMap[params.newValue.toInteger()] : params.newValue.toInteger() )
      

      changing the last line to include brackets makes it work

      Eval.x(el[0],"x[1]="+ (el[2] ? trendMap[params.newValue.toInteger()] : params.newValue.toInteger()) )
      

      Exception thrown

      BUG! exception in phase 'parsing' in source unit 'Script1.groovy' null

      at groovy.util.Eval.me(Eval.java:50)

      at groovy.util.Eval.x(Eval.java:60)

      at groovy.util.Eval$x.call(Unknown Source)

      at ConsoleScript24.run(ConsoleScript24:9)

      Caused by: java.lang.NullPointerException

      at java.io.StringReader.<init>(StringReader.java:33)

      ... 4 more
      Result: 23
      Exception thrown

      BUG! exception in phase 'parsing' in source unit 'Script1.groovy' null

      at groovy.util.Eval.me(Eval.java:50)

      at groovy.util.Eval.x(Eval.java:60)

      at groovy.util.Eval$x.call(Unknown Source)

      at ConsoleScript26.run(ConsoleScript26:9)

      Caused by: java.lang.NullPointerException

      at java.io.StringReader.<init>(StringReader.java:33)

      ... 4 more

        Attachments

        1. 4293_v17x.patch
          1.0 kB
          Roshan Dawrani

          Activity

            People

            • Assignee:
              roshandawrani Roshan Dawrani
              Reporter:
              livelock André
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: