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

Sylwester Lachiewicz updated THRIFT-6342:
-----------------------------------------
    Description: 
[t_haxe_generator::render_const_value|https://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/generate/t_haxe_generator.cc#L593]
 writes {{(byte)N}} for an {{i8}} constant and {{(short)N}} for an {{i16}} 
constant. Haxe has no cast of that form, and the field they initialise is 
declared {{haxe.Int32}} anyway.

{code}
const i8 SMALL = 7
const i16 MEDIUM = 300
{code}
{noformat}
$ thrift --gen haxe repro.thrift && grep "SMALL\|MEDIUM" 
gen-haxe/ReproConstants.hx
  public static inline var SMALL : haxe.Int32 = (byte)7;
  public static inline var MEDIUM : haxe.Int32 = (short)300;
{noformat}

The same casts appear wherever an {{i8}} or {{i16}} value is rendered, 
including elements of container constants ({{tmp.add((byte)1)}}, 
{{tmp.set((short)1, ...)}}), for example in {{test/DebugProtoTest.thrift}}. The 
generated file does not compile. Writing the plain integer, as the {{i32}} case 
does, is enough. Reproduced on master at 3af0cfff1.

  was:
[t_haxe_generator::render_const_value|https://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/generate/t_haxe_generator.cc#L593]
 writes {{(byte)N}} for an {{i8}} constant and {{(short)N}} for an {{i16}} 
constant. Haxe has no cast of that form, and the field they initialise is 
declared {{haxe.Int32}} anyway.

{code}
const i8 SMALL = 7
const i16 MEDIUM = 300
{code}
{noformat}
$ thrift --gen haxe repro.thrift && grep "SMALL\|MEDIUM" 
gen-haxe/ReproConstants.hx
  public static inline var SMALL : haxe.Int32 = (byte)7;
  public static inline var MEDIUM : haxe.Int32 = (short)300;
{noformat}

The generated file does not compile. Writing the plain integer, as the {{i32}} 
case does, is enough. Reproduced on master at 3af0cfff1.


> Haxe generator renders i8 and i16 constants with C-style casts
> --------------------------------------------------------------
>
>                 Key: THRIFT-6342
>                 URL: https://issues.apache.org/jira/browse/THRIFT-6342
>             Project: Thrift
>          Issue Type: Bug
>          Components: Haxe - Compiler
>    Affects Versions: 0.25.0
>            Reporter: Sylwester Lachiewicz
>            Priority: Major
>
> [t_haxe_generator::render_const_value|https://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/generate/t_haxe_generator.cc#L593]
>  writes {{(byte)N}} for an {{i8}} constant and {{(short)N}} for an {{i16}} 
> constant. Haxe has no cast of that form, and the field they initialise is 
> declared {{haxe.Int32}} anyway.
> {code}
> const i8 SMALL = 7
> const i16 MEDIUM = 300
> {code}
> {noformat}
> $ thrift --gen haxe repro.thrift && grep "SMALL\|MEDIUM" 
> gen-haxe/ReproConstants.hx
>   public static inline var SMALL : haxe.Int32 = (byte)7;
>   public static inline var MEDIUM : haxe.Int32 = (short)300;
> {noformat}
> The same casts appear wherever an {{i8}} or {{i16}} value is rendered, 
> including elements of container constants ({{tmp.add((byte)1)}}, 
> {{tmp.set((short)1, ...)}}), for example in {{test/DebugProtoTest.thrift}}. 
> The generated file does not compile. Writing the plain integer, as the 
> {{i32}} case does, is enough. Reproduced on master at 3af0cfff1.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to