Copilot commented on code in PR #3529:
URL: https://github.com/apache/thrift/pull/3529#discussion_r3352162198


##########
compiler/cpp/src/thrift/generate/t_js_generator.cc:
##########
@@ -2587,7 +2643,14 @@ void t_js_generator::generate_serialize_field(ostream& 
out, t_field* tfield, str
         out << "writeI32(" << name << ")";
         break;
       case t_base_type::TYPE_I64:
-        out << "writeI64(" << name << ")";
+        // In bigint mode the generated field holds a `bigint`; convert
+        // back to a node-int64 Int64 before handing to `writeI64`, which
+        // expects either an Int64 or a Number.
+        if (gen_bigint_) {
+          out << "writeI64(thrift.fromBigInt(" << name << "))";
+        } else {
+          out << "writeI64(" << name << ")";
+        }

Review Comment:
   In `gen_bigint_` mode, `TYPE_I64` serialization always emits 
`thrift.fromBigInt(<expr>)`. This breaks `map<i64, ...>` serialization because 
map keys are iterated as **strings** (`for (kiter in obj)`), so generated code 
ends up calling `thrift.fromBigInt(kiter)` where `kiter` is a string, throwing 
a TypeError. The default `js:bigint=true` would therefore make i64-keyed maps 
fail at runtime when writing.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to