groovy-notifications mailing list archives

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


Paul King commented on GROOVY-6148:

Changing the {{multipleAssignmentDeclarationStart}} definition in the grammar from:
(modifier nls | annotation nls)* "def" nls LPAREN
(modifier nls | annotation nls | "def" nls)+ LPAREN
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:
@Lazy() (x, y) = [1, 2]
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:
>             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

View raw message