[ 
https://issues.apache.org/jira/browse/THRIFT-787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12915455#action_12915455
 ] 

Christian Lavoie commented on THRIFT-787:
-----------------------------------------

I generated code with all generators, using a simplistic enum:

{code}
enum MyEnum {
  ZERO,
  ONE,
  THREE = 3,
  FOUR,
  FORTYTWO = 42,
  FORTYTHREE,
  TWELVE = 12,
  THIRTEEN
}
{code}

{noformat}
9050e1c444bb9ec823857e68f1ea3c6e  tmp-without-787/gen-as3/MyEnum.as
e364dd1d37f48f5ee49898273d583ac3  tmp-without-787/gen-cocoa/test.h
13353d093c7fbfb6d34e18c5e209834e  tmp-without-787/gen-cocoa/test.m
0e35d18e6b3d161050416ef65f589a7b  tmp-without-787/gen-cpp/test_constants.cpp
0305410c79ead19f7a21da83005bbc4d  tmp-without-787/gen-cpp/test_constants.h
d614d268bf718712f9857febe59a87a5  tmp-without-787/gen-cpp/test_types.cpp
f4202dd6e56eb234e9ff319fd5248b58  tmp-without-787/gen-cpp/test_types.h
44537aa869bdf2c22d2a40427eb7bfbb  tmp-without-787/gen-csharp/MyEnum.cs
5cc5162f68c30a8ff998f0ba28afd1ec  tmp-without-787/gen-erl/test_constants.hrl
01ea91d8c4d3ba7fe0c4568aecf66636  tmp-without-787/gen-erl/test_types.erl
80fcb1e546073b806fc1676176330477  tmp-without-787/gen-erl/test_types.hrl
515131db34af21096383eadc718905ab  tmp-without-787/gen-hs/Test_Consts.hs
c65c348912562e58a25d4448b5881f06  tmp-without-787/gen-hs/Test_Types.hs
7de88e95d2037748dd0f3917b5645265  tmp-without-787/gen-html/index.html
c6e33f8d8d4b88f37d666ed8392d24cb  tmp-without-787/gen-html/style.css
6d86e7f688a70ab75289fbfe14f67f39  tmp-without-787/gen-html/test.html
53183bfed8fb46399da51ad849758e4e  tmp-without-787/gen-java/MyEnum.java
1f32e388a639a566394a1f6611cebea6  tmp-without-787/gen-javame/MyEnum.java
ae31c442df8f2982efbd3bbcbf6c6ddd  tmp-without-787/gen-js/test_types.js
ad2f732e3f82c4d02baf90b5800ed4b0  tmp-without-787/gen-ocaml/test_consts.ml
27a042e3e8a036dbcb374a8103ea7d35  tmp-without-787/gen-ocaml/test_types.ml
0e2fe71b03b241ff4c2b5c1a4b36e208  tmp-without-787/gen-ocaml/test_types.mli
de37caf4bb38ca4399b31850dddcd0ec  tmp-without-787/gen-perl/Constants.pm
07be59e6b0ce725187869ebc1d2c9a14  tmp-without-787/gen-perl/Types.pm
fd9fd449f522a983f545d3dbb038ad4b  tmp-without-787/gen-php/test/test_types.php
d41d8cd98f00b204e9800998ecf8427e  tmp-without-787/gen-py/__init__.py
fcb6376ae0410613e38952e6b0395814  tmp-without-787/gen-py/test/__init__.py
14e2d529821f06f285353a86634e673b  tmp-without-787/gen-py/test/constants.py
94c4a93659d81bc9b48ad2519ea9a37f  tmp-without-787/gen-py/test/ttypes.py
8096a712cd33880d33dca92b11671472  tmp-without-787/gen-rb/test_constants.rb
28a82f55b1a1d74e5e7882292f1eab8b  tmp-without-787/gen-rb/test_types.rb
76c2d5049d0c0b0df90cec6760815ecb  tmp-without-787/gen-st/test.st
718d8596a14d123d83afb0d5d6d6fd96  tmp-without-787/gen-xsd/test_xsd.php
{noformat}

Then again, after apply my v2 patch:

{noformat}
9050e1c444bb9ec823857e68f1ea3c6e  tmp-with-787/gen-as3/MyEnum.as
e364dd1d37f48f5ee49898273d583ac3  tmp-with-787/gen-cocoa/test.h
13353d093c7fbfb6d34e18c5e209834e  tmp-with-787/gen-cocoa/test.m
0e35d18e6b3d161050416ef65f589a7b  tmp-with-787/gen-cpp/test_constants.cpp
0305410c79ead19f7a21da83005bbc4d  tmp-with-787/gen-cpp/test_constants.h
d614d268bf718712f9857febe59a87a5  tmp-with-787/gen-cpp/test_types.cpp
f4202dd6e56eb234e9ff319fd5248b58  tmp-with-787/gen-cpp/test_types.h
44537aa869bdf2c22d2a40427eb7bfbb  tmp-with-787/gen-csharp/MyEnum.cs
5cc5162f68c30a8ff998f0ba28afd1ec  tmp-with-787/gen-erl/test_constants.hrl
01ea91d8c4d3ba7fe0c4568aecf66636  tmp-with-787/gen-erl/test_types.erl
80fcb1e546073b806fc1676176330477  tmp-with-787/gen-erl/test_types.hrl
515131db34af21096383eadc718905ab  tmp-with-787/gen-hs/Test_Consts.hs
c65c348912562e58a25d4448b5881f06  tmp-with-787/gen-hs/Test_Types.hs
7de88e95d2037748dd0f3917b5645265  tmp-with-787/gen-html/index.html
c6e33f8d8d4b88f37d666ed8392d24cb  tmp-with-787/gen-html/style.css
6d86e7f688a70ab75289fbfe14f67f39  tmp-with-787/gen-html/test.html
53183bfed8fb46399da51ad849758e4e  tmp-with-787/gen-java/MyEnum.java
1f32e388a639a566394a1f6611cebea6  tmp-with-787/gen-javame/MyEnum.java
ae31c442df8f2982efbd3bbcbf6c6ddd  tmp-with-787/gen-js/test_types.js
ad2f732e3f82c4d02baf90b5800ed4b0  tmp-with-787/gen-ocaml/test_consts.ml
27a042e3e8a036dbcb374a8103ea7d35  tmp-with-787/gen-ocaml/test_types.ml
0e2fe71b03b241ff4c2b5c1a4b36e208  tmp-with-787/gen-ocaml/test_types.mli
de37caf4bb38ca4399b31850dddcd0ec  tmp-with-787/gen-perl/Constants.pm
07be59e6b0ce725187869ebc1d2c9a14  tmp-with-787/gen-perl/Types.pm
fd9fd449f522a983f545d3dbb038ad4b  tmp-with-787/gen-php/test/test_types.php
d41d8cd98f00b204e9800998ecf8427e  tmp-with-787/gen-py/__init__.py
fcb6376ae0410613e38952e6b0395814  tmp-with-787/gen-py/test/__init__.py
14e2d529821f06f285353a86634e673b  tmp-with-787/gen-py/test/constants.py
94c4a93659d81bc9b48ad2519ea9a37f  tmp-with-787/gen-py/test/ttypes.py
8096a712cd33880d33dca92b11671472  tmp-with-787/gen-rb/test_constants.rb
28a82f55b1a1d74e5e7882292f1eab8b  tmp-with-787/gen-rb/test_types.rb
e74e255a131e643e8a887efcebe31156  tmp-with-787/gen-st/test.st
718d8596a14d123d83afb0d5d6d6fd96  tmp-with-787/gen-xsd/test_xsd.php
{noformat}

They're the same files, so the patch is clearly a no-op from that perspective. 
Also, I read through the generated code, it is "obviously correct", meaning 
that {{ZERO}} matches with {{0}}, {{THIRTEEN}} with {{13}}, ... in all 
generated code. Diff'ing leads to the same conclusion:

{noformat}

$ diff --recursive tmp-with*
diff --recursive tmp-with-787/gen-st/test.st tmp-without-787/gen-st/test.st
15c15
< !Test class methodsFor: 'as yet uncategorized' stamp: 'thrift 09/27/2010 
15:57'!
---
> !Test class methodsFor: 'as yet uncategorized' stamp: 'thrift 09/27/2010 
> 15:54'!
19c19
< !Test class methodsFor: 'as yet uncategorized' stamp: 'thrift 09/27/2010 
15:57'!
---
> !Test class methodsFor: 'as yet uncategorized' stamp: 'thrift 09/27/2010 
> 15:54'!
23c23
< !Test class methodsFor: 'as yet uncategorized' stamp: 'thrift 09/27/2010 
15:57'!
---
> !Test class methodsFor: 'as yet uncategorized' stamp: 'thrift 09/27/2010 
> 15:54'!
27c27
< !Test class methodsFor: 'as yet uncategorized' stamp: 'thrift 09/27/2010 
15:57'!
---
> !Test class methodsFor: 'as yet uncategorized' stamp: 'thrift 09/27/2010 
> 15:54'!
{noformat}

The only difference is some timestamp in the st generator.

> Enums are not read correctly
> ----------------------------
>
>                 Key: THRIFT-787
>                 URL: https://issues.apache.org/jira/browse/THRIFT-787
>             Project: Thrift
>          Issue Type: Bug
>          Components: Haskell - Compiler
>    Affects Versions: 0.1
>         Environment: All platforms
>            Reporter: Spiridon Eliopoulos
>            Assignee: Spiridon Eliopoulos
>            Priority: Minor
>             Fix For: 0.5
>
>         Attachments: 0001--THRIFT-787-Fix-bug-in-enum-deserialization.patch, 
> v2-thrift-read-enums-cleanup.patch
>
>
> The Haskell (and OCaml) generators emit incorrect code for enum 
> deserilalization. The value counter is not reset to -1 before the 
> deserialization function is generated.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to