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

+= and -= no longer rejected in assertion statement in Groovy 3

    XMLWordPrintableJSON

Details

    • Question
    • Status: Closed
    • Minor
    • Resolution: Not A Problem
    • 3.0.0-rc-2
    • None
    • parser-antlr4
    • None

    Description

      Playing with the failures which Groovy 3 brought to Spock tests itself,
      I noticed that Groovy 3 no longer rejects += and -= if used in an
      assertion statement:

      //Groovy 3-rc2
      def a = 1
      assert a += 1 //passes
      assert a == 2 //passes
      

      While it behaves consistently, I wonder if that change was introduced purposely (it was failing in Groovy 2) and should be documented or the check should be enhanced?

      //Groovy 2.5
      startup failed:
      Script1.groovy: 3: unexpected token: += @ line 1, column 10.
         assert a += 1
                  ^1 error
      

      https://github.com/apache/groovy/commit/a17b9eb85835a5eaa306a893a0a8bcd51a49e299#diff-05fe8708ce3207739a2cb39a97426e8dR345

      Follow up of the mailing list thread.

      Attachments

        Activity

          People

            Unassigned Unassigned
            szpak Marcin Zajaczkowski
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: