Groovy
  1. Groovy
  2. GROOVY-5195

GroovyConsole reports "unexpected token" on method name after @Grab

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: 1.8.4
    • Fix Version/s: None
    • Component/s: Compiler, Groovy Console
    • Labels:
    • Environment:
      Windows 7 (64 bit)

      Description

      The following script:

      @Grab( group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.1' )

      println "x"

      yields "unexpected token: println at line: 3, column: 1"

      However, inserting "def z" in a line before println compiles correctly. Oddly, adding parenthesis:

      @Grab( group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.1' )

      println ("x")

      changes the error to: unexpected token: x at line: 3, column: 10

      So, I expect there's something about the syntax of @Grab (or @?) that is allowing for the possibility of more text related to it such that the method 'println' is ambiguous but 'def' clearly terminates the @Grab and starts a new element. A minor thing, but confusing.

        Activity

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Closed Closed
        5d 21h 29m 1 Jochen Theodorou 20/Dec/11 09:52
        Closed Closed Reopened Reopened
        2h 23m 1 Jochen Theodorou 20/Dec/11 12:16
        Reopened Reopened Closed Closed
        11s 1 Jochen Theodorou 20/Dec/11 12:16
        Mark Thomas made changes -
        Workflow jira [ 12971603 ] Default workflow, editable Closed status [ 12979393 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12734120 ] Default workflow, editable Closed status [ 12745883 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Jochen Theodorou made changes -
        Resolution Won't Fix [ 2 ]
        Status Reopened [ 4 ] Closed [ 6 ]
        Jochen Theodorou made changes -
        Resolution Fixed [ 1 ]
        Status Closed [ 6 ] Reopened [ 4 ]
        Jochen Theodorou made changes -
        Field Original Value New Value
        Assignee Jochen Theodorou [ blackdrag ]
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Closed [ 6 ]
        Hide
        Jochen Theodorou added a comment -

        the problem is more that you cannot yet annotate a method call. We intend to change this in the long term, but we have to diverge from Java on this, since Java annotations don't allow for that at all.

        Of course the error message is better in the later case, still it is not accepted by the grammar in both cases.

        Show
        Jochen Theodorou added a comment - the problem is more that you cannot yet annotate a method call. We intend to change this in the long term, but we have to diverge from Java on this, since Java annotations don't allow for that at all. Of course the error message is better in the later case, still it is not accepted by the grammar in both cases.
        James Higgins-Thomas created issue -

          People

          • Assignee:
            Jochen Theodorou
            Reporter:
            James Higgins-Thomas
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development