[ https://issues.apache.org/jira/browse/THRIFT-2587?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Nevo Hed updated THRIFT-2587: ----------------------------- Comment: was deleted (was: This is probably a syntax error in my thrift file. Adding the enum name in the default value makes the double "common" go away and replaced with a proper refrence {code:title=myapi.thrift|borderStyle=solid} include "common.thrift" namespace java com.example.someapi struct MyStruct { 1: optional common.SomeEnum val=common.SomeEnum.SOMEENUM_X } {code} This seems to be because the logic of [get_identifier_with_parent|https://git-wip-us.apache.org/repos/asf?p=thrift.git;a=blob;f=compiler/cpp/src/parse/t_const_value.h;h=ff422ae4690a4bdd5d1bac4dc4adf3b130c755ae;hb=HEAD#l148] which skips the first dot-separated keyword IFF at least 2 dots exist Ideally the thrift compiler would alert on this, but that seems to be out of scope of this issue ) > Compiler should fully validate default values > --------------------------------------------- > > Key: THRIFT-2587 > URL: https://issues.apache.org/jira/browse/THRIFT-2587 > Project: Thrift > Issue Type: Bug > Components: Compiler (General) > Affects Versions: 0.9.1, 0.9.2 > Reporter: Nevo Hed > > The compiler seems to accept an incomplete symbol specification. This may > yield unusable code in some target languages. > Example yielding bad Java code: > {code:title=common.thrift|borderStyle=solid} > namespace java com.example.common > enum SomeEnum { > SOMEENUM_X, > } > {code} > {code:title=myapi.thrift (incorrect enum reference)|borderStyle=solid} > include "common.thrift" > namespace java com.example.someapi > struct MyStruct { > 1: optional common.SomeEnum val=common.SOMEENUM_X > } > {code} > The correct reference would have been: > {code:title=myapi.thrift (correct enum reference)|borderStyle=solid} > include "common.thrift" > namespace java com.example.someapi > struct MyStruct { > 1: optional common.SomeEnum val=common.SomeEnum.SOMEENUM_X > } > {code} > But the thrift compiler does not complain, and so the generated Java code > contains "common" twice, with no type name. > {code} > $ grep SOMEENUM_ gen-java/com/example/someapi/MyStruct.java > this.val = com.example.common.common.SOMEENUM_X; > this.val = com.example.common.common.SOMEENUM_X; > {code} -- This message was sent by Atlassian JIRA (v6.2#6252)