You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Jeff DeCew (JIRA)" <ji...@apache.org> on 2010/08/25 20:32:17 UTC

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

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


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.


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

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917822#action_12917822 ] 

David Reiss commented on THRIFT-868:
------------------------------------

Why not just put the version you have in t_typedef directly in t_type?

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


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

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

Bryan Duxbury updated THRIFT-868:
---------------------------------

    Fix Version/s: 0.6
                       (was: 0.5)

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


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

Posted by "Igor Ribeiro de Assis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917820#action_12917820 ] 

Igor Ribeiro de Assis commented on THRIFT-868:
----------------------------------------------

Yeah, it's better. New patch attached.

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


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

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

Igor Ribeiro de Assis updated THRIFT-868:
-----------------------------------------

    Attachment: THRIFT-868-v2_Referencing_constant_values_dont_work_with_typedefs.patch

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


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

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

Igor Ribeiro de Assis updated THRIFT-868:
-----------------------------------------

    Attachment: THRIFT-868-v3_Referencing_constant_values_dont_work_with_typedefs.patch

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


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

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917770#action_12917770 ] 

David Reiss commented on THRIFT-868:
------------------------------------

Ick.  Maybe it would be better to make get_true_type a method of t_type and make the t_program version just be a wrapper?

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


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

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

Igor Ribeiro de Assis updated THRIFT-868:
-----------------------------------------

    Attachment: THIRFT-868_Referencing_constant_values_dont_work_with_typedefs.patch

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


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

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917866#action_12917866 ] 

David Reiss commented on THRIFT-868:
------------------------------------

Oh, I see.  Is it an include order thing?  Let me play around with it for a bit and see if I can find something I like.

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


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

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


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

Posted by "Igor Ribeiro de Assis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917741#action_12917741 ] 

Igor Ribeiro de Assis commented on THRIFT-868:
----------------------------------------------

Yes. But needed to make some changes to avoid forward declaration errors and make get_true_type public (it was protected).

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


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

Posted by "Igor Ribeiro de Assis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917828#action_12917828 ] 

Igor Ribeiro de Assis commented on THRIFT-868:
----------------------------------------------

Ok, but then I would need to move get_type to t_type or am I missing something?

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


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

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917863#action_12917863 ] 

David Reiss commented on THRIFT-868:
------------------------------------

I don't think so, because get_true_type is casting the type pointer to a t_typedef*.

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


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

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917670#action_12917670 ] 

David Reiss commented on THRIFT-868:
------------------------------------

Can you use the true_type method instead of hard-coding the loop?

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


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

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

David Reiss updated THRIFT-868:
-------------------------------

    Attachment: v5-0002-THRIFT-868.-Make-const-values-work-properly-with-typ.patch
                v5-0001-compiler-Move-t_type-generate_fingerprint-to-a-.cc-f.patch

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


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

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917864#action_12917864 ] 

David Reiss commented on THRIFT-868:
------------------------------------

Oh, also, can you use spaces instead of tabs for indentation?

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


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

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

Igor Ribeiro de Assis updated THRIFT-868:
-----------------------------------------

    Attachment: THRIFT-868-v1_Referencing_constant_values_dont_work_with_typedefs.patch

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


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

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917883#action_12917883 ] 

David Reiss commented on THRIFT-868:
------------------------------------

What do you think of this version?  I started with a separate diff to create parse.cc, so a t_type function can reference t_typedef.

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


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

Posted by "Igor Ribeiro de Assis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917979#action_12917979 ] 

Igor Ribeiro de Assis commented on THRIFT-868:
----------------------------------------------

Looks good to me.

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


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

Posted by "Bryan Duxbury (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12908864#action_12908864 ] 

Bryan Duxbury commented on THRIFT-868:
--------------------------------------

I looked into this a little bit, and it looks like the problem is that somehow resolve_const_value isn't doing its job correctly. I tried doing a little bit of work to resolve the typedef to the underlying type, but that didn't do it. Someone is going to have to dig in a little deeper.

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


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

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

Igor Ribeiro de Assis updated THRIFT-868:
-----------------------------------------

    Attachment: THRIFT-868-v4_Referencing_constant_values_dont_work_with_typedefs.patch

Using spaces instead of tabs.

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


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

Posted by "Igor Ribeiro de Assis (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12917273#action_12917273 ] 

Igor Ribeiro de Assis commented on THRIFT-868:
----------------------------------------------

Hey Bryan I did exactly that and it seemed to work. Are there any other tests you did that failed?

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