Repository: groovy
Updated Branches:
  refs/heads/GROOVY_2_4_X c6438dd03 -> 1739cdc4c


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


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/1739cdc4
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/1739cdc4
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/1739cdc4

Branch: refs/heads/GROOVY_2_4_X
Commit: 1739cdc4cfcde5c75fd5e4a8678db90c695af81c
Parents: c6438dd
Author: paulk <pa...@asert.com.au>
Authored: Fri Mar 4 14:41:11 2016 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Mon Mar 7 16:48:09 2016 +1000

----------------------------------------------------------------------
 src/main/org/codehaus/groovy/antlr/groovy.g |  4 ++--
 src/test/gls/enums/EnumTest.groovy          | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/1739cdc4/src/main/org/codehaus/groovy/antlr/groovy.g
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/antlr/groovy.g 
b/src/main/org/codehaus/groovy/antlr/groovy.g
index aadf519..0efbd4b 100644
--- a/src/main/org/codehaus/groovy/antlr/groovy.g
+++ b/src/main/org/codehaus/groovy/antlr/groovy.g
@@ -1230,12 +1230,12 @@ enumConstants
     :
         enumConstant
         (    options {generateAmbigWarnings=false;} :
-            (nls (RCURLY | classField)) => { break; /* leave ()* loop */ }
+            (nls (SEMI! | RCURLY | classField)) => { break; /* leave ()* loop 
*/ }
         |   nls! COMMA!
             (
                 (nls annotationsOpt IDENT) => nls! enumConstant
             |
-                (nls (RCURLY | classField)) => { break; /* leave ()* loop */ }
+                (nls (SEMI! | RCURLY | classField)) => { break; /* leave ()* 
loop */ }
             )
         )*
     ;

http://git-wip-us.apache.org/repos/asf/groovy/blob/1739cdc4/src/test/gls/enums/EnumTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/gls/enums/EnumTest.groovy 
b/src/test/gls/enums/EnumTest.groovy
index 8f9c152..f858dfd 100644
--- a/src/test/gls/enums/EnumTest.groovy
+++ b/src/test/gls/enums/EnumTest.groovy
@@ -577,6 +577,21 @@ class EnumTest extends CompilableTestSupport {
             println Foonum.Y
         '''
     }
+
+    void testEnumWithPropertiesAndDanglingComma_GROOVY_7773() {
+        assertScript '''
+            enum UsState {
+                ID('Idaho'),
+                IL('Illinois'),
+                IN('Indiana'),
+                ;
+                UsState( String value ) { this.value = value }
+                private final String value
+                String toString() { value }
+            }
+            assert UsState.ID.toString() == 'Idaho'
+        '''
+    }
 }
 
 enum UsCoin {

Reply via email to