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

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

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.8
    • Fix Version/s: 2.6.0-alpha-1
    • Component/s: Compiler
    • Labels:
      None
    • Environment:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: