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

ASF GitHub Bot commented on GROOVY-7773:
----------------------------------------

GitHub user paulk-asert opened a pull request:

    https://github.com/apache/groovy/pull/279

    GROOVY-7773: Enum constructor with value throws "unexpected token" er…

    …ror (closes #279)

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/paulk-asert/groovy groovy7773

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/groovy/pull/279.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #279
    
----
commit 5b5a166c9e7cd89a7064bef369dbd96f599e5e7a
Author: paulk <[email protected]>
Date:   2016-03-04T04:41:11Z

    GROOVY-7773: Enum constructor with value throws "unexpected token" error 
(closes #279)

----


> Enum constructor with value throws "unexpected token" error
> -----------------------------------------------------------
>
>                 Key: GROOVY-7773
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7773
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>    Affects Versions: 2.4.6
>         Environment: Windows 7 Professional
> JDK 1.8.0_45
>            Reporter: Brian Ray
>            Priority: Minor
>
> First time submitter to this JIRA so let me know if I've specified anything 
> incorrectly. I just upgraded from 2.4.4 to 2.4.6 and now declaring an enum 
> constructor accepting a value as follows:
> {code:title=UsStates.groovy}
> enum UsState {
>   
>   ID('Idaho'),
>   IL('Illinois'),
>   IN('Indiana'),
>   
>   UsState( String value ) { this.value = value }
>   private final String value
>   
>   String toString() { return value }
> }
> println UsState.ID //Idaho
> {code}
> throws the following compile error:
> {code}
> org.codehaus.groovy.control.MultipleCompilationErrorsException: startup 
> failed:
> C:\svn_qa\jenkins_trunk\scripts\UsStates.groovy: 7: unexpected token: this @ 
> line 7, column 29.
>      UsState( String value ) { this.value = value }
>                                ^
> 1 error
> {code}
> No such error occurred in 2.4.4, nor does it happen in 2.4.5. Here are a few 
> contrasting things that do seem to work in 2.4.6:
> {code:title=UsStatesBoring.groovy}
> enum UsState {
>   
>   ID,
>   IL,
>   IN,
> }
> println UsState.ID //ID
> {code}
> {code:title=UsStatesNoEnum.groovy}
> class UsState {
>   
>   UsState( String value ) { this.value = value }
>   private final String value
>   
>   String toString() { return value }
> }
> final idaho = new UsState('Idaho')
> println idaho //Idaho
> {code}
> Though this seems higher priority than Minor, I can work around it by simply 
> downgrading to 2.4.5. I wish there was a Medium priority.



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

Reply via email to