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

Final variable analysis giving incorrect message within nested if

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.x
    • 2.5.0-beta-3
    • Compiler
    • None

    Description

      def method() {
          final z = null
          if (z != null) {
              z = 3
          }
      }
      

      gives error message:

      1 compilation error:
      The variable [z] may be uninitialized
      . At [5:11]  at line: 5, column: 11
      

      it should be a compile error since we are reassigning z, but the error message should be:

      The variable [z] is declared final but is reassigned
      

      Attachments

        Activity

          People

            paulk Paul King
            paulk Paul King
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: