[
https://issues.apache.org/jira/browse/THRIFT-532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12728329#action_12728329
]
Ying-Yi Liang commented on THRIFT-532:
--------------------------------------
Please ignore the patch of "enum_value_less_aggressive.diff", since it is
wrong. That patch does not correctly deal with this case:
enum Numberz {
ZERO,
ONE,
TWO,
MOREZERO = 0
}
The reason is that it starts assigning implicit values without anticipation of
the same explicit value. Doing a pre-scan to mark down the occupied values
should fix this issue. Besides, the aggressive but less backward compatible
patch "enum_value.diff" is fine.
> Implicit enum value generation is incorrect
> -------------------------------------------
>
> Key: THRIFT-532
> URL: https://issues.apache.org/jira/browse/THRIFT-532
> Project: Thrift
> Issue Type: Bug
> Components: Compiler (General)
> Affects Versions: 0.2
> Reporter: Ying-Yi Liang
> Priority: Minor
> Attachments: enum_value.diff, enum_value_less_agressive.diff
>
>
> For languages without native enum support (e.g. Java, PHP...), the Thrift
> compiler automatically assigns a value to enum members without explicit
> values. The current algorithm assumes explicit values are in ascending order,
> which does not always hold...
> See below for a violation case:
> enum ValueCollision {
> TWO,
> ONE = 1,
> THREE
> }
> The implicit value of TWO collides with ONE...A simple solution is to make
> the smallest implicit value greater than the largest explicit value.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.