Repository: capnproto/capnproto-rust (language: rust)

Issue:
Problem with floating point numeric literals
A 0 is hardcoded in the compiler but used with floating point types as in https://github.com/millere/osiris/blob/3cc9adc1d5fb698b8e1aa6b8dbba07b471395303/net/src/proto.capn and https://github.com/millere/osiris/blob/3cc9adc1d5fb698b8e1aa6b8dbba07b471395303/net/src/proto_capnp.rs#L80



Discussion / hints:

Fix patch:
diff --git a/src/capnpc-rust/codegen.rs b/src/capnpc-rust/codegen.rs
index a0d1b69d3..c60b39a7f 100644
--- a/src/capnpc-rust/codegen.rs
+++ b/src/capnpc-rust/codegen.rs
@@ -517,7 +517,7 @@ fn zero_fields_of_group(node_map : &collections::hashmap::HashMap<u64, schema_ca
                                     type_::Uint8(()) | type_::Uint16(()) | type_::Uint32(()) |
                                     type_::Uint64(()) | type_::Float32(()) | type_::Float64(()) |
                                     type_::Enum(_) => {
-                                        let line = Line(format!("self.builder.set_data_field::<{}>({}, 0);",
+                                        let line = Line(format!("self.builder.set_data_field::<{0}>({1}, 0 as {0});",
                                                          prim_type_str(typ),
                                                          slot.get_offset()));
                                         // PERF could dedup more efficiently


Test patch: