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

&& operator is not handled correctly in some cases when it starts a new line

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.3.8
    • 2.6.0-alpha-1
    • Compiler
    • None
    • CentOS 7

    Description

      Repro

      A.groovy
      def files = new File(".").list(
          [ accept: { d, f ->
              (f ==~ ".*") && !f.endsWith(".tmp")
          }] as FilenameFilter
      ).toList()
      

      Result: works fine

      B.groovy
      def files = new File(".").list(
          [ accept: { d, f ->
              (f ==~ ".*")
                  && !f.endsWith(".tmp")
          }] as FilenameFilter
      ).toList()
      

      Result:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      /home/csbubbles/B.groovy: 5: unexpected token: && @ line 5, column 3.
         		&& !f.endsWith(".tmp")
           ^
      
      1 error
      

      Expected results

      B.groovy should get executed successfully the same way as A.groovy, as its two lines in a closure is the only expression.

      PS "return" statement doesn't help if you put it before "(f ==~ ".*")" either.

      Attachments

        Activity

          People

            jwagenleitner John Wagenleitner
            csbubbles Maxim Novikov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: