Miles, > On 13. 5. 2024, at 17:43, Milles, Eric (TR Technology) via dev > <dev@groovy.apache.org> wrote: > When the parser cannot work out the meaning, it tends to report "unexpected > input".
I don't complain at all that the error is reported as an “unexpected input”; I do apologise I haven't explained it in detail in my original e-mail, seemed to me sort of obvious, mea culpa. My complaint is that it reports the error very very far from the place it actually occurs. If the “unexpected input“ was reported at the extra “)”, or about anywhere at the same line, it would be completely all right and I'd be happy. What stroke me as seriously misleading is that the error is reported at a perfectly valid “{” at the very beginning of the block. It can happen with much longer blocks just as well, in which case the potential for confusion is even considerably bigger: === 1025 ocs /tmp> <q.groovy def all=['hi','there'].findAll { def foo=it+'bar' if (foo.length>7) return false // yadda yadda... // ... looks like essentially any number... // ... of rows can be here it.startsWith('h')) // *NOTE* bug is here! The compiler is really not helping at all finding and fixing it } 1026 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 32. def all=['hi','there'].findAll { ^ 1 error 1027 ocs /tmp> === The problem seems to occur with closures only. If the findAll at the first line is replaced by something like for (s in ['hi','there']) {, the error would be reported properly at the right place, at the extra ')'. > There is a ticket about parser recovery that may address some types of errors > like the extra closing paren in your example. But it has not gotten off the > ground. > > https://issues.apache.org/jira/browse/GROOVY-9192 > > You can also keep an eye on all the Parrot Parser bugs here: > > https://issues.apache.org/jira/issues/?jql=project+%3D+GROOVY+AND+component+%3D+parser-antlr4 Thanks, I'll check in there when I get more time. All the best, OC