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

Semicolon required after coercing to a parameterized (generic) type containing a parameterized (generic) type as its only or last type argument when there is no space between the ending ">>"

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.6
    • Fix Version/s: 2.6.0-alpha-1
    • Component/s: parser-antlr
    • Labels:
      None

      Description

      It seems that after coercing an object to a parameterized (generic) type containing a parameterized (generic) type as its only or last type argument without putting any space between the ending ">>", a semicolon is needed.

      Example:

      $ groovy -v
      Groovy Version: 1.8.6 JVM: 1.6.0_30 Vendor: Sun Microsystems Inc. OS: Linux
      $ groovy -e "def list = [1,2,3,4] as List<Integer>
      println list
      println 'bye'" # This works fine.
      [1, 2, 3, 4]
      bye
      $ groovy -e "def list = [[1,2],[3,4]] as List<List<Integer>>
      println list
      println 'bye'" # This should work fine, but does not.
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      script_from_command_line: 2: expecting EOF, found 'println' @ line 2, column 1.
      println list
      ^

      1 error

      $ groovy -e "def list = [[1,2],[3,4]] as List<List<Integer> >
      println list
      println 'bye'" # After adding a space between ">>", this works fine.
      [[1, 2], [3, 4]]
      bye
      $ groovy -e "def list = [[1,2],[3,4]] as List<List<Integer>>;
      println list
      println 'bye'" # Or, after adding a semicolon, this works fine.
      [[1, 2], [3, 4]]
      bye
      $

        Issue Links

          Activity

          Hide
          adastragrl Amy Chuo added a comment -

          Also, I confirmed that GROOVY-2725 is indeed fixed when I try out the exact test case in there, so I'm curious why whatever fixed that didn't fix this...

          Show
          adastragrl Amy Chuo added a comment - Also, I confirmed that GROOVY-2725 is indeed fixed when I try out the exact test case in there, so I'm curious why whatever fixed that didn't fix this...
          Hide
          paulk Paul King added a comment -

          My guess is the ">>" operator is picked up in the parsing and there is nothing after the ">>" which wouldn't be valid after a real ">>". It would be nice if we could tweak the grammar guards/priorities to avoid this.

          Show
          paulk Paul King added a comment - My guess is the ">>" operator is picked up in the parsing and there is nothing after the ">>" which wouldn't be valid after a real ">>". It would be nice if we could tweak the grammar guards/priorities to avoid this.
          Hide
          daniel_sun Daniel Sun added a comment -

          Fixed in the parrot branch

          Show
          daniel_sun Daniel Sun added a comment - Fixed in the parrot branch

            People

            • Assignee:
              daniel_sun Daniel Sun
              Reporter:
              adastragrl Amy Chuo
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development