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

unexpected parsing of command chain with nested command chain

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.5.2
    • Fix Version/s: None
    • Component/s: Groovy Console
    • Labels:
    • Environment:
      jdk: oracle jdk 1.8.0_191
      groovy: 2.5.2
      os: windows

      Description

      I'm using groovyConsole to see the generated class code of the following two Groovy scripts:

      process test{
          output:
          file 'output.txt' into b, c
      
          """
          echo hello
          """
      }
      

      Here is its generated code snippet like below:

      public java.lang.Object run() {
      this.process(this.test({ 
      this.file('output.txt').into(b, c)
      '\n echo hello\n '
      }))
      }
      

      And here is the second script that differs from the previous one - this one uses parentheses in file() method invocation:

      process test{
          output:
          file('output.txt') into b, c
      
          """
          echo hello
          """
      }
      

      And this is generated code from the second script:

      public java.lang.Object run() {
      process.test({ 
      this.file('output.txt').into(b, c)
      '\n echo hello\n '
      })
      }
      

       As you can see, process is no longer a function but a variable. It confuses me because I would expect that in both cases process should be seen as a function call. Is this an expected behavior? Do I miss something?

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              crabime ShaoXian Song
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: