You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Raymond Chee (Jira)" <ji...@apache.org> on 2022/03/16 04:16:00 UTC

[jira] [Updated] (THRIFT-5540) Can't use a typedef for a container type containing enums in a constant

     [ https://issues.apache.org/jira/browse/THRIFT-5540?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Raymond Chee updated THRIFT-5540:
---------------------------------
    Description: 
This small thrift file fails to compile.
{code:java}
enum SomeEnum {
    A,
    B,
    C
}
typedef map<SomeEnum, i32> SomeMap
const SomeMap MY_MAP = {
    SomeEnum.A: 123,
    SomeEnum.B: 456,
    SomeEnum.C: 789
}
 {code}
Trying to compile this thrift file results in this error: 
{code:java}
[FAILURE:generation:1] Error: have identifier "SomeEnum.A", but unset enum on line!{code}
 

If I didn't use the typedef and instead declared MY_MAP with type map<SomeEnum, i32>, there is no issues with compilation. This issue also happens if SomeEnum is the value type in the map, and is also present for typedefs of lists of enums.

  was:
This small thrift file fails to compile.

 
{code:java}
enum SomeEnum {
    A,
    B,
    C
}
typedef map<SomeEnum, i32> SomeMap
const SomeMap MY_MAP = {
    SomeEnum.A: 123,
    SomeEnum.B: 456,
    SomeEnum.C: 789
}
 {code}
Trying to compile this thrift file results in this error: 
{code:java}
[FAILURE:generation:1] Error: have identifier "SomeEnum.A", but unset enum on line!{code}
 

If I didn't use the typedef and instead declared MY_MAP with type map<SomeEnum, i32>, there is no issues with compilation. This issue also happens if SomeEnum is the value type in the map, and is also present for typedefs of lists of enums.


> Can't use a typedef for a container type containing enums in a constant
> -----------------------------------------------------------------------
>
>                 Key: THRIFT-5540
>                 URL: https://issues.apache.org/jira/browse/THRIFT-5540
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (General)
>    Affects Versions: 0.16.0
>            Reporter: Raymond Chee
>            Priority: Minor
>
> This small thrift file fails to compile.
> {code:java}
> enum SomeEnum {
>     A,
>     B,
>     C
> }
> typedef map<SomeEnum, i32> SomeMap
> const SomeMap MY_MAP = {
>     SomeEnum.A: 123,
>     SomeEnum.B: 456,
>     SomeEnum.C: 789
> }
>  {code}
> Trying to compile this thrift file results in this error: 
> {code:java}
> [FAILURE:generation:1] Error: have identifier "SomeEnum.A", but unset enum on line!{code}
>  
> If I didn't use the typedef and instead declared MY_MAP with type map<SomeEnum, i32>, there is no issues with compilation. This issue also happens if SomeEnum is the value type in the map, and is also present for typedefs of lists of enums.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)