You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Nathan Marz (JIRA)" <ji...@apache.org> on 2010/02/25 02:24:27 UTC

[jira] Created: (THRIFT-716) Field names can conflict with local variables in code for unions

Field names can conflict with local variables in code for unions
----------------------------------------------------------------

                 Key: THRIFT-716
                 URL: https://issues.apache.org/jira/browse/THRIFT-716
             Project: Thrift
          Issue Type: Bug
          Components: Compiler (Java)
            Reporter: Nathan Marz


Try creating a union with the field name "value", and the code won't compile. In writeFields for the generated class, you'll have something like the following:

<code>
      case VALUE:
        String value = (String)getFieldValue();
        oprot.writeString(value);
        return;
</code>

"String value" conflicts with the parameter "Object value".

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


[jira] Commented: (THRIFT-716) Field names can conflict with local variables in code for unions

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

Bryan Duxbury commented on THRIFT-716:
--------------------------------------

That would happen, wouldn't it? The solution is just to rename the internal value var to something like __value__. Feel like submitting a patch?

> Field names can conflict with local variables in code for unions
> ----------------------------------------------------------------
>
>                 Key: THRIFT-716
>                 URL: https://issues.apache.org/jira/browse/THRIFT-716
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Java)
>            Reporter: Nathan Marz
>
> Try creating a union with the field name "value", and the code won't compile. In writeFields for the generated class, you'll have something like the following:
> <code>
>       case VALUE:
>         String value = (String)getFieldValue();
>         oprot.writeString(value);
>         return;
> </code>
> "String value" conflicts with the parameter "Object value".

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


[jira] Commented: (THRIFT-716) Field names can conflict with local variables in code for unions

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

David Reiss commented on THRIFT-716:
------------------------------------

How about "_value"?  Thrift identifiers shouldn't be starting with underscores.

> Field names can conflict with local variables in code for unions
> ----------------------------------------------------------------
>
>                 Key: THRIFT-716
>                 URL: https://issues.apache.org/jira/browse/THRIFT-716
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Java)
>            Reporter: Nathan Marz
>
> Try creating a union with the field name "value", and the code won't compile. In writeFields for the generated class, you'll have something like the following:
> <code>
>       case VALUE:
>         String value = (String)getFieldValue();
>         oprot.writeString(value);
>         return;
> </code>
> "String value" conflicts with the parameter "Object value".

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


[jira] Assigned: (THRIFT-716) Field names can conflict with local variables in code for unions

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

Bryan Duxbury reassigned THRIFT-716:
------------------------------------

    Assignee: Bryan Duxbury

> Field names can conflict with local variables in code for unions
> ----------------------------------------------------------------
>
>                 Key: THRIFT-716
>                 URL: https://issues.apache.org/jira/browse/THRIFT-716
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Java)
>            Reporter: Nathan Marz
>            Assignee: Bryan Duxbury
>         Attachments: thrift-716.patch
>
>
> Try creating a union with the field name "value", and the code won't compile. In writeFields for the generated class, you'll have something like the following:
> <code>
>       case VALUE:
>         String value = (String)getFieldValue();
>         oprot.writeString(value);
>         return;
> </code>
> "String value" conflicts with the parameter "Object value".

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


[jira] Updated: (THRIFT-716) Field names can conflict with local variables in code for unions

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

Bryan Duxbury updated THRIFT-716:
---------------------------------

    Attachment: thrift-716.patch

In looking at this issue, I realized that there's actually no reason to make the value to write a parameter to writeField, since the generated class will have access to the protected value variable in the base class. This patch reflects the removal of the value (and set field) parameters from the signature of writeField and updates to the generator accordingly.

What do you guys think?

> Field names can conflict with local variables in code for unions
> ----------------------------------------------------------------
>
>                 Key: THRIFT-716
>                 URL: https://issues.apache.org/jira/browse/THRIFT-716
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Java)
>            Reporter: Nathan Marz
>         Attachments: thrift-716.patch
>
>
> Try creating a union with the field name "value", and the code won't compile. In writeFields for the generated class, you'll have something like the following:
> <code>
>       case VALUE:
>         String value = (String)getFieldValue();
>         oprot.writeString(value);
>         return;
> </code>
> "String value" conflicts with the parameter "Object value".

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


[jira] Closed: (THRIFT-716) Field names can conflict with local variables in code for unions

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

Bryan Duxbury closed THRIFT-716.
--------------------------------

    Resolution: Fixed

I just committed this.

> Field names can conflict with local variables in code for unions
> ----------------------------------------------------------------
>
>                 Key: THRIFT-716
>                 URL: https://issues.apache.org/jira/browse/THRIFT-716
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Java)
>            Reporter: Nathan Marz
>            Assignee: Bryan Duxbury
>         Attachments: thrift-716.patch
>
>
> Try creating a union with the field name "value", and the code won't compile. In writeFields for the generated class, you'll have something like the following:
> <code>
>       case VALUE:
>         String value = (String)getFieldValue();
>         oprot.writeString(value);
>         return;
> </code>
> "String value" conflicts with the parameter "Object value".

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


[jira] Commented: (THRIFT-716) Field names can conflict with local variables in code for unions

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

David Reiss commented on THRIFT-716:
------------------------------------

Looks fine to me if it works.

> Field names can conflict with local variables in code for unions
> ----------------------------------------------------------------
>
>                 Key: THRIFT-716
>                 URL: https://issues.apache.org/jira/browse/THRIFT-716
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Java)
>            Reporter: Nathan Marz
>            Assignee: Bryan Duxbury
>         Attachments: thrift-716.patch
>
>
> Try creating a union with the field name "value", and the code won't compile. In writeFields for the generated class, you'll have something like the following:
> <code>
>       case VALUE:
>         String value = (String)getFieldValue();
>         oprot.writeString(value);
>         return;
> </code>
> "String value" conflicts with the parameter "Object value".

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