From bbefba4229cd5d5c38840c8765d7ea7e2597e123 Mon Sep 17 00:00:00 2001 From: vyzo Date: Fri, 9 Feb 2024 23:20:41 +0200 Subject: [PATCH] fix bug in protobuf expansion (#1115) unchecked call to write-varint* ... with arguments in the wrong order. :facepalm: --- src/std/protobuf/macros.ss | 2 +- src/std/protobuf/protobuf-test.ss | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/std/protobuf/macros.ss b/src/std/protobuf/macros.ss index 803da8b89..f83a0485c 100644 --- a/src/std/protobuf/macros.ss +++ b/src/std/protobuf/macros.ss @@ -51,7 +51,7 @@ ((cases ...) (map (lambda (key val) (with-syntax ((key key) (val val)) - #'((key) (&BufferedWriter-write-varint* val buf)))) + #'((key) (&BufferedWriter-write-varint* buf val)))) keys vals))) #'(defwriter-ext* (bio-write buf val) (case val diff --git a/src/std/protobuf/protobuf-test.ss b/src/std/protobuf/protobuf-test.ss index f079508d7..e0639d877 100644 --- a/src/std/protobuf/protobuf-test.ss +++ b/src/std/protobuf/protobuf-test.ss @@ -86,6 +86,22 @@ BufferedReader-read-Test7 BufferedWriter-write-Test7) ) + (test-case "test enum" + (defenum E + (a 1) + (b 2) + (c 3)) + + (defmessage A + optional: (a 1 E)) + + (check-marshal-unmarshal (A a: 'a) + BufferedReader-read-A BufferedWriter-write-A) + (check-marshal-unmarshal (A a: 'b) + BufferedReader-read-A BufferedWriter-write-A) + (check-marshal-unmarshal (A a: 'c) + BufferedReader-read-A BufferedWriter-write-A)) + (test-case "test oneof" (defmessage A oneof: (a (s 1 string) (i 2 int32)))