Jochen,
> On 15. 5. 2024, at 14:18, Jochen Theodorou <[email protected]> wrote:
> On 13.05.24 16:16, [email protected] 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: "[email protected]" <[email protected]>
> 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: [email protected]
> Reply-To: [email protected]
>
> 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