You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Jens Geyer (Jira)" <ji...@apache.org> on 2026/05/14 22:03:00 UTC

[jira] [Assigned] (THRIFT-5992) Haxe generator: keyword escaping, stdlib-type renaming, typedef import and FIELD_ID fixes

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

Jens Geyer reassigned THRIFT-5992:
----------------------------------

    Assignee: Jens Geyer

> Haxe generator: keyword escaping, stdlib-type renaming, typedef import and FIELD_ID fixes
> -----------------------------------------------------------------------------------------
>
>                 Key: THRIFT-5992
>                 URL: https://issues.apache.org/jira/browse/THRIFT-5992
>             Project: Thrift
>          Issue Type: Bug
>          Components: Haxe - Compiler
>            Reporter: Jens Geyer
>            Assignee: Jens Geyer
>            Priority: Major
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> The Haxe code generator has several related issues that cause generated code to fail to compile:
> 1. *Reserved keyword collision*: Haxe has 45 reserved keywords (e.g. {{var}}, {{function}}, {{class}}, {{import}}, {{if}}, {{for}}, etc.). When a Thrift field, parameter, or local variable name matches one of these, the generated Haxe code is syntactically invalid. Fix: add an {{escape_haxe_keyword()}} helper and apply it at all field/parameter/local-variable naming sites.
> 2. *Stdlib type name collision*: When the capitalized form of a Thrift type name matches a Haxe standard-library type (e.g. {{Map}}, {{Set}}, {{List}}, {{Enum}}, {{Lambda}}, {{Date}}, {{Type}}, {{Math}}, {{Reflect}}, {{Std}}, etc.), the generated identifier silently shadows the stdlib type, causing compilation errors. Fix: extend {{get_cap_name()}} to append {{_}} when the result conflicts with a known stdlib type name.
> 3. *Spurious import for base-type typedefs*: When a Thrift typedef aliases a base type (e.g. {{typedef i32 MyInt}}), the generator emits an {{import}} for it even though no Haxe class file is generated for base-type typedefs. This produces an unresolvable import error. Fix: {{haxe_thrift_add_import()}} now skips base-type typedef targets.
> 4. *FIELD_ID constant name mismatch*: In {{generate_reflection_getters()}} and {{generate_reflection_setters()}}, the FIELD_ID constant is referenced using the raw field name rather than the escaped name. When the field name is a reserved keyword, the constant is generated under the escaped name (e.g. {{var_}} FIELD_ID) but referenced under the raw name, causing a compilation error. Fix: use the escaped name consistently.
> 5. *Test script Linux/macOS compatibility*: {{run-Haxe-Codegen-Tests.ps1}} used Windows path separators in {{InitializeFolder}} calls. Fixed for cross-platform compatibility.



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