groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Paul King (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-6148) Multiple definition should allow final
Date Thu, 02 Jun 2016 07:07:59 GMT

    [ https://issues.apache.org/jira/browse/GROOVY-6148?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15311851#comment-15311851
] 

Paul King commented on GROOVY-6148:
-----------------------------------

Changing the {{multipleAssignmentDeclarationStart}} definition in the grammar from:
{code}
(modifier nls | annotation nls)* "def" nls LPAREN
{code}
to
{code}
(modifier nls | annotation nls | "def" nls)+ LPAREN
{code}
Seems to be the change required. And seems like a reasonable change for modifiers.

It does make the use of attributeless annotations a little confusing. Not that we currently
support it but if you wanted to have something like @Lazy annotating a multi-assignment, you
would need need something like:
{code}
@Lazy() (x, y) = [1, 2]
{code}
Note the empty brackets after @Lazy which could normally be elided but not here. Otherwise
the (x, y) would be mistaken as attributes for the annotation.

> Multiple definition should allow final
> --------------------------------------
>
>                 Key: GROOVY-6148
>                 URL: https://issues.apache.org/jira/browse/GROOVY-6148
>             Project: Groovy
>          Issue Type: Bug
>          Components: syntax
>            Reporter: Russel Winder
>
> The line:
> {quote}
> def (x, y) = l.split()
> {quote}
> works fine. However, the line:
> {quote}
> final (x, y) = l.split()
> {quote}
> fails with a compile error. If def gives a rebindable variable and final gives an unrebindable
variable in other places it should here as well.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message