[
https://issues.apache.org/jira/browse/GROOVY-8131?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15942478#comment-15942478
]
Paul King commented on GROOVY-8131:
-----------------------------------
If you compile your static final example with the latest snapshot versions of
Groovy you will get:
{noformat}
The variable [s3] may be uninitialized
{noformat}
But in some sense that isn't what your main point is, so I won't dwell on that.
Perhaps if you think of newline as a statement terminator, that will explain
the current behavior. We do some but not very much lookahead. You are right
that we could do smarter lookahead within the grammar but it isn't trivial.
As an example, Groovy allows this statement:
{code}
multiply 4 by 5
{code}
which is the same as:
{code}
multiply(4).by(5)
{code}
With an implementation like:
{code}
def multiply(multiplicand) { [by: { multiplier -> multiplicand * multiplier }] }
{code}
Where as this:
{code}
multiply 4
by 5
{code}
Are these two valid statements:
{code}
multiply(4)
by(5)
{code}
> Statement continued onto next line is flagged when first character is "="
> -------------------------------------------------------------------------
>
> Key: GROOVY-8131
> URL: https://issues.apache.org/jira/browse/GROOVY-8131
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 2.4.5
> Environment: Ubuntu Linux
> `uname -a`:
> Linux biostar 4.4.0-69-generic #90-Ubuntu SMP Thu Mar 16 16:52:31 UTC 2017
> x86_64 x86_64 x86_64 GNU/Linux
> Reporter: Richard Elkins
> Priority: Minor
> Attachments: grbug.java
>
>
> Source code attached (grbug.java).
> `javac` v8 compiles variable declarations s1, s2, and s3 successfully.
> `groovyc` flags s3:
> "unexpected token: = @ line 9, column 3."
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)