Jochen Kemnade created GROOVY-12792:
---------------------------------------

             Summary: Syntax error is reported at the first nested method call 
instead of at the actual error (regression in 6.0.0)
                 Key: GROOVY-12792
                 URL: https://issues.apache.org/jira/browse/GROOVY-12792
             Project: Groovy
          Issue Type: Improvement
          Components: parser-antlr4
    Affects Versions: 6.0.0
            Reporter: Jochen Kemnade


h3. Description

If a source file contains a method call that has another method call as 
argument (e.g. {{foo(bar(1))}}) and a syntax error somewhere *later* in another 
member or class, Groovy 6.0.0 reports the error at the opening parenthesis of 
the inner call ({{Missing ')'}}), however far away the actual error is. Groovy 
4.0.28, 5.0.5, 5.1.2 and 6.0.0-alpha-2 report the actual position.

h3. Reproducer

{code:java}
class A {
    def a() { x.y(z(1)) }
    def b(class c) { }
}
{code}

||Groovy||Message||
|6.0.0|Missing ')' @ line 2, column 20.|
|6.0.0-alpha-2, 5.1.2, 5.0.5, 4.0.28|Unexpected input: 'class' @ line 3, column 
11.|

h3. Observations

* The actual error can be of any kind, as long as it is in a different member 
or class than the nested call: invalid parameter list ({{def b(int a, )}}), 
{{def x = ;}}, {{foo(1 }}, {{class B extends \{}}. An error inside the same 
method body as the nested call is reported correctly.
* If several nested calls precede the error, the first one is reported.
* A call with a literal argument ({{f(1)}}) does not trigger it. A nested call 
in a field initializer ({{def a = x.y(z(1))}}) does. Script code is affected as 
well ({{foo(bar(1))}} followed by an invalid method declaration).
* The same message is reported when parsing SLL-first with LL fallback (stock 
behaviour) and with LL only.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to