~bigbes/tarantool-protobuf: f5c5ee6c

codec: preserve -0.0 for proto3 float/double scalars

Proto3 default-elision dropped any singular float/double whose value
compared equal to 0 — `-0.0 == 0.0` in IEEE so the `if v ~= 0` guard
silently elided negative zero. The wire bytes for -0 differ from +0
and the TextFormatInput conformance corpus pins that -0 must survive
a round-trip; the failure surfaced as 10 unexpected text-suite
regressions covering FloatFieldNegativeZero (3 spellings × 2 outputs)
and Neg{Float,Double}FieldLargeNegativeExponentParsesAsNegZero
(2 types × 2 outputs).

Sign-bit guard via `1/v == math.huge` (positive zero yields +inf,
negative zero yields -inf). Applied in three layers:
  * runtime/pb/codec.lua: is_default_scalar + the specialized
    monomorphic writer for non-optional numeric scalars
  * runtime/pb/text.lua: is_proto3_default (text encoder elision)
  * inline codegen: scalarNotDefaultExpr emits the guard for
    float/double fields in full-mode `_encode` functions

Proto3 text-format conformance now sits at 416 ✓ / 18 skipped / 0
expected failures; binary+JSON holds at 1478 ✓. Unit-test regressions
cover both directions (preserved on encode + decode round-trip, +0
still elided) and use a runtime-computed -0.0 sentinel because LuaJIT
can constant-fold the literal `-0.0` to a sign-less zero in some
load paths.

Eugene Blikh <bigbes@gmail.com> — 2026-05-16 16:21:32 UTC

Commit f5c5ee6c333c5f993cfaf4e3870d01f7b6d71b35view raw patch

Parent(s): 7ec8f2b4

7 changed file(s)

FileStatus+
cmd/protoc-gen-tarantool/internal/gen/inline.go M +8
examples/expected/full/hello/hello_pb.lua M +1 -1
examples/expected/full/protobuf_test_messages/proto3/test_messages_proto3_pb.lua M +4 -4
runtime/pb/codec.lua M +20 -1
runtime/pb/text.lua M +6
test/conformance/known_failures_text.txt M +4 -29
test/protobuf_test.lua M +25