You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Spiridon Eliopoulos (JIRA)" <ji...@apache.org> on 2010/05/22 18:44:16 UTC

[jira] Created: (THRIFT-787) Enums are not read correctly

Enums are not read correctly
----------------------------

                 Key: THRIFT-787
                 URL: https://issues.apache.org/jira/browse/THRIFT-787
             Project: Thrift
          Issue Type: Bug
          Components: Compiler (Haskell)
    Affects Versions: 0.1
         Environment: All platforms
            Reporter: Spiridon Eliopoulos
            Assignee: Spiridon Eliopoulos
            Priority: Minor


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.


[jira] Commented: (THRIFT-787) Enums are not read correctly

Posted by "Christian Lavoie (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Updated: (THRIFT-787) Enums are not read correctly

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-787?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Duxbury updated THRIFT-787:
---------------------------------

    Fix Version/s: 0.5

> 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.


[jira] Issue Comment Edited: (THRIFT-787) Enums are not read correctly

Posted by "Christian Lavoie (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12914898#action_12914898 ] 

Christian Lavoie edited comment on THRIFT-787 at 9/25/10 9:20 PM:
------------------------------------------------------------------

Actually, this is now handled in parse/t_enum.*, the resolve_values call. It's implemented redundantly in (as far as I can tell) all generators the same way:

{noformat}
 286   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
 287     if ((*c_iter)->has_value()) {
 288       value = (*c_iter)->get_value();
 289     } else {
 290       ++value; // THIS WILL NEVER EXECUTE
 291     }
 292     string name = capitalize((*c_iter)->get_name());
 293 
 294     f_types_ <<
 295       indent() << name << " -> " << value << endl;
 296   }
{noformat}

(or the appropriate variant thereof)

So this patch is now redundant (thanks to resolve_values, the else branch of that if statement is never taken in the generators). Cleanup patch incoming as soon as I have a setup where I can run tests.

      was (Author: clavoie):
    Actually, this is now handled in parse/t_enum.*, the resolve_values call. It's implemented redundantly in (as far as I can tell) all generators the same way:

 286   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
 287     if ((*c_iter)->has_value()) {
 288       value = (*c_iter)->get_value();
 289     } else {
 290       ++value; // THIS WILL NEVER EXECUTE
 291     }
 292     string name = capitalize((*c_iter)->get_name());
 293 
 294     f_types_ <<
 295       indent() << name << " -> " << value << endl;
 296   }

(or the appropriate variant thereof)

So this patch is now redundant (thanks to resolve_values, the else branch of that if statement is never taken in the generators). Cleanup patch incoming as soon as I have a setup where I can run tests.
  
> 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
>         Attachments: 0001--THRIFT-787-Fix-bug-in-enum-deserialization.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.


[jira] Commented: (THRIFT-787) Enums are not read correctly

Posted by "Christian Lavoie (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12914898#action_12914898 ] 

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

Actually, this is now handled in parse/t_enum.*, the resolve_values call. It's implemented redundantly in (as far as I can tell) all generators the same way:

 286   for (c_iter = constants.begin(); c_iter != constants.end(); ++c_iter) {
 287     if ((*c_iter)->has_value()) {
 288       value = (*c_iter)->get_value();
 289     } else {
 290       ++value; // THIS WILL NEVER EXECUTE
 291     }
 292     string name = capitalize((*c_iter)->get_name());
 293 
 294     f_types_ <<
 295       indent() << name << " -> " << value << endl;
 296   }

(or the appropriate variant thereof)

So this patch is now redundant (thanks to resolve_values, the else branch of that if statement is never taken in the generators). Cleanup patch incoming as soon as I have a setup where I can run tests.

> 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
>         Attachments: 0001--THRIFT-787-Fix-bug-in-enum-deserialization.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.


[jira] Closed: (THRIFT-787) Enums are not read correctly

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-787?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Duxbury closed THRIFT-787.
--------------------------------

      Assignee: Christian Lavoie  (was: Spiridon Eliopoulos)
    Resolution: Fixed

I just committed this. There were a few other little blobs of calls to the has_value() method in as3, python, and cpp compilers that seemed superfluous, so I whacked those too. Thanks for the patch, Christian!

> 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: Christian Lavoie
>            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.


[jira] Updated: (THRIFT-787) Enums are not read correctly

Posted by "Spiridon Eliopoulos (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-787?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Spiridon Eliopoulos updated THRIFT-787:
---------------------------------------

    Attachment: 0001--THRIFT-787-Fix-bug-in-enum-deserialization.patch

This patch fixes this issue.

> Enums are not read correctly
> ----------------------------
>
>                 Key: THRIFT-787
>                 URL: https://issues.apache.org/jira/browse/THRIFT-787
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Haskell)
>    Affects Versions: 0.1
>         Environment: All platforms
>            Reporter: Spiridon Eliopoulos
>            Assignee: Spiridon Eliopoulos
>            Priority: Minor
>         Attachments: 0001--THRIFT-787-Fix-bug-in-enum-deserialization.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.


[jira] Updated: (THRIFT-787) Enums are not read correctly

Posted by "Christian Lavoie (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-787?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Christian Lavoie updated THRIFT-787:
------------------------------------

    Attachment: v2-thrift-read-enums-cleanup.patch

Haven't tested this yet, but reading the code produced by the compiler, it all looks 'obviously correct' to me (keep in mind I don't speak as3, cocoa, csharp, erl, php, st or xsd fluently).

I should be able test about half the generators first hand this week, if nobody beats me to it.

> 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
>         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.