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 16:47:00 UTC
[jira] [Created] (THRIFT-5994) Haxe generator: map, map, map and set equivalents generate invalid ObjectMap/ObjectSet
Jens Geyer created THRIFT-5994:
----------------------------------
Summary: Haxe generator: map<bool,V>, map<double,V>, map<binary,V> and set equivalents generate invalid ObjectMap/ObjectSet
Key: THRIFT-5994
URL: https://issues.apache.org/jira/browse/THRIFT-5994
Project: Thrift
Issue Type: Bug
Components: Haxe - Compiler, Haxe - Library
Reporter: Jens Geyer
When a Thrift IDL file uses {{bool}}, {{double}}, or {{binary}} as a map key type or set element type, the Haxe generator emits {{ObjectMap<Bool,V>}}, {{ObjectMap<Float,V>}}, {{ObjectMap<Bytes,V>}}, {{ObjectSet<Bool>}}, {{ObjectSet<Float>}}, or {{ObjectSet<Bytes>}}. These usages are all invalid:
- {{ObjectMap<K,V>}} and {{ObjectSet<K>}} require {{K : {}}} (a reference/object type constraint). {{Bool}} and {{Float}} are Haxe value types that do not satisfy this constraint, causing a compile-time type error.
- {{Bytes}} satisfies the constraint structurally, but {{ObjectMap}}/{{ObjectSet}} use reference equality. Two equal {{Bytes}} values at different addresses are treated as distinct keys/elements, producing semantically incorrect behaviour.
Fix: add three new helper classes to the Thrift Haxe library:
- {{BoolMap<T>}} / {{BoolSet}}: implement {{haxe.Constraints.IMap<Bool,T>}} backed by {{IntMap<T>}} / {{IntMap<Int>}} with encoding {{k ? 1 : 0}}.
- {{FloatMap<T>}} / {{FloatSet}}: implement {{haxe.Constraints.IMap<Float,T>}} backed by {{StringMap<T>}} / {{StringMap<Int>}} with keys stored as 8-byte IEEE 754 hex strings (via {{Bytes.setDouble}}), giving exact equality semantics including NaN, -0.0, and infinities.
- {{BytesMap<T>}} / {{BytesSet}}: implement {{haxe.Constraints.IMap<Bytes,T>}} backed by {{StringMap<T>}} / {{StringMap<Int>}} with keys stored as hex strings ({{Bytes.toHex}}), giving content equality semantics.
Wire the new types in {{type_name()}}: {{map<bool,V>}} -> {{BoolMap}}, {{map<double,V>}} -> {{FloatMap}}, {{map<binary,V>}} -> {{BytesMap}}; {{set<bool>}} -> {{BoolSet}}, {{set<double>}} -> {{FloatSet}}, {{set<binary>}} -> {{BytesSet}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)