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

wrong placement of error report in a closure

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.0.3, 4.0.21
    • None
    • parser-antlr4
    • None

    Description

      Probably affects all Groovy 3 and 4 (possibly 5, haven't tried), but not Groovy 2. Perhaps the Parrot parser? Groovy 3.0.3 is the oldest I've tested; alas the Affects Versions does not allow entering something like “3+”, which would make more sense I think.

      Some errors in closures are reported as an unexpected input (which is all right) at the opening { of the closure (that's not OK). E.g.,

      1035 ocs /tmp> /usr/local/groovy-4.0.21/bin/groovy q
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      /private/tmp/q.groovy: 1: Unexpected input: '{' @ line 1, column 10.
         10.times { bar()) }
                  ^ 

      Happens with longer multi-line closures as well, which might lead to a really inconvenient search for the real culprit.

      Note that normal non-closure blocks are not affected:

      1036 ocs /tmp> /usr/local/groovy-4.0.21/bin/groovy w
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      /private/tmp/w.groovy: 1: Unexpected input: '{ foo())' @ line 1, column 31.
         for (int n=0;n<10;n++) { foo()) }
                                       ^ 

      Attachments

        Activity

          People

            Unassigned Unassigned
            oc OC
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: