Jochen, > On 15. 5. 2024, at 14:18, Jochen Theodorou <blackd...@gmx.org> wrote: > On 13.05.24 16:16, o...@ocs.cz wrote: > [...] >> 2074 ocs /tmp> <q.groovy >> def all=['hi','there'].findAll { it.startsWith('h')) } >> 2075 ocs /tmp> /usr/local/groovy-4.0.18/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 { it.startsWith('h')) } >> ^ >> 1 error >> 2076 ocs /tmp> >> === > > I assume the problem is the )) for the startsWith.
Quite. I think other errors might cause the same problem, but I haven't tested it further now. On the other hand, I have meantime recalled I've bumped into this before, see please also the forwarded message below, which remained unanswered since I dumbly posted into users, not dev. > The parser backtracks because there is no opening ( for the closing one and > then finds that { can't be a valid input here. I see. On the other hand, with a normal non-closure block the error is reported properly: === 1039 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: '{ bar())' @ line 1, column 15. if (0) { bar()) } ^ 1 error 1040 ocs /tmp> === > Could you please make an issue for this? We should look into how we can > improve this https://issues.apache.org/jira/browse/GROOVY-11377 Thanks and all the best, OC > Begin forwarded message: > > From: "o...@ocs.cz" <o...@ocs.cz> > Subject: misplaced else inside a closure causes wrong (or at least pretty > weird) error placement with Parrot > Date: 19 May 2020 at 22:36:06 CEST > To: us...@groovy.apache.org > Reply-To: us...@groovy.apache.org > > Hi there, > > perhaps this is a known or well-understand issue, but worth reporting IMHO > (not sure whether worth a ticket; let me please know should I create one for > this): > > === > 281 ocs /tmp> <q.groovy > class q { > def foo(val) { > 10.times { > println "Essentially anything..." > > > > println "... can be here, the longer this code, the worse" > else println "This is wrong, but see the error report!" > } > } > } > 282 ocs /tmp> /usr/local/groovy-2.4.17/bin/groovyc q.groovy > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > q.groovy: 9: unexpected token: else @ line 9, column 7. > else println "This is wrong, but see the error report!" > ^ > 1 error > 283 ocs /tmp> /usr/local/groovy-3.0.3/bin/groovyc q.groovy > org.codehaus.groovy.control.MultipleCompilationErrorsException: startup > failed: > q.groovy: 3: Unexpected input: '{'; Expecting RBRACE @ line 3, column 14. > 10.times { > ^ > 1 error > 284 ocs /tmp> > === > > All the best, > OC