[
https://issues.apache.org/jira/browse/THRIFT-532?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12726672#action_12726672
]
Ying-Yi Liang commented on THRIFT-532:
--------------------------------------
The patch will definitely change the numbering of the existing constants, which
means there would be some client/server semantic inconsistency if the two sides
use different versions of Thrift compiler.
Another solution more compatible with the original method is to maintain an
occupation list. Implicit value assignment still goes the same way as it was
except that we check whether there is a value conflict before using it as the
final value. Such solution still changes the numbering if there is a value
conflict in the original output, but...that was incorrect...
BTW: implicit enum value assignment is basically the same in all generators.
Shouldn't there be a parse-tree resolution pass dealing with these issues
before handing it down to the generators?
> 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
>
>
> 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.