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

[jira] Resolved: (THRIFT-868) Referencing constant values doesn't work with with typedef types

     [ https://issues.apache.org/jira/browse/THRIFT-868?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Reiss resolved THRIFT-868.
--------------------------------

    Resolution: Fixed

Thanks for tracking this down.

> Referencing constant values doesn't work with with typedef types
> ----------------------------------------------------------------
>
>                 Key: THRIFT-868
>                 URL: https://issues.apache.org/jira/browse/THRIFT-868
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (General)
>    Affects Versions: 0.4
>            Reporter: Jeff DeCew
>            Priority: Minor
>             Fix For: 0.6
>
>         Attachments: THIRFT-868_Referencing_constant_values_dont_work_with_typedefs.patch, THRIFT-868-v1_Referencing_constant_values_dont_work_with_typedefs.patch, THRIFT-868-v2_Referencing_constant_values_dont_work_with_typedefs.patch, THRIFT-868-v3_Referencing_constant_values_dont_work_with_typedefs.patch, THRIFT-868-v4_Referencing_constant_values_dont_work_with_typedefs.patch, v5-0001-compiler-Move-t_type-generate_fingerprint-to-a-.cc-f.patch, v5-0002-THRIFT-868.-Make-const-values-work-properly-with-typ.patch
>
>
> Setting a constant's value to the value of another constant does not work when the types are typedefs.  The workaround is easy, but it devalues the typedef.
> Here's my example input:
> {code:title=Test.thrift}
> // test with strings
> const string str_a = "foo"
> const string str_b = str_a
> typedef string MyString
> const MyString mystr_a = "bar"
> const MyString mystr_b = mystr_a // results in empty string
> // Test with ints
> const i32 int_x = 42
> const i32 int_y = int_x
> typedef i32 MyInt
> const MyInt myint_x = 29
> const MyInt myint_y = myint_x // causes compiler error - code generator ends prematurely
> {code}
> Which erroneously results in the following:
> {code:title=Constants.java}
> public class Constants {
>     public static final String str_a = "foo";
>     public static final String str_b = "foo";
>     public static final String mystr_a = "bar";
>     public static final String mystr_b = "";
>     public static final int int_x = 42;
>     public static final int int_y = 42;
>     public static final int myint_x = 29;
>     public static final int 
> <<eof>>
> {code}
> The string typedef fails silently, ignoring the value and using "" instead, while the i32 typedef successfully parses, but causes the code generator to error out mid-file.  There are clearly two very different symptoms here, but my gut tells me that they have the same root cause.

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