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

With bug - http://groovyconsole.appspot.com/script/596001

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Not A Problem
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Ref: http://groovyconsole.appspot.com/script/596001

      String test() { 
          [].with { 
              "hello " + foofoo
          } 
      } 
      
      println test() // prints "hello []"
      

        Activity

        Hide
        roshandawrani Roshan Dawrani added a comment -

        Looking closer, this doesn't seem like a bug. Effectively what kicks-in in the code below is the equivalent of "assert (['aa', 'bbb'].count) == [2, 3]"

        String test() { 
            [].with { 
               "hello " + foofoo
            } 
        } 
        

        In the above snippet, resolution of 'foofoo' property inside the with closure with [] as the delegate (and resolution strategy DELEGATE_FIRST) becomes [].foofoo, which results in [], which is the normal Groovy behavior.

        Show
        roshandawrani Roshan Dawrani added a comment - Looking closer, this doesn't seem like a bug. Effectively what kicks-in in the code below is the equivalent of "assert ( ['aa', 'bbb'] .count) == [2, 3] " String test() { [].with { "hello " + foofoo } } In the above snippet, resolution of 'foofoo' property inside the with closure with [] as the delegate (and resolution strategy DELEGATE_FIRST) becomes [].foofoo, which results in [], which is the normal Groovy behavior.

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development