Repository: groovy
Updated Branches:
  refs/heads/master c2d80bc8b -> d72b48118


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/d72b4811
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/d72b4811
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/d72b4811

Branch: refs/heads/master
Commit: d72b48118f9b0efb287119ca72662d739ebf0d0d
Parents: c2d80bc
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:46:58 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/d72b4811/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 9ca3abb..72a748e 100644
--- a/src/main/org/codehaus/groovy/antlr/groovy.g
+++ b/src/main/org/codehaus/groovy/antlr/groovy.g
@@ -1192,12 +1192,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/d72b4811/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