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

Switch return statement transformation misses last case without break

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.14, 3.0.7, 4.0.0-alpha-2
    • 2.5.15, 3.0.8, 4.0.0-alpha-3
    • None
    • None

    Description

      Consider the following:

      def test(str) {
        switch(str) {
         case 'foo':
         case 'bar':
          'value'
        //break
        }
      }
      println test('foo')
      println test('bar')
      println test('baz')
      

      When this script is executed, it prints "null" three times. If the break statement is added, it prints "value", "value", "null" as expected. ReturnAdder only transforms case blocks that end with break. This is possibly the reason GROOVY-4727 fails.

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h