From 62f25af06c39636d5e09d85753d3e958f264eec1 Mon Sep 17 00:00:00 2001 From: Ryan Ofsky Date: Wed, 1 Jul 2026 18:23:58 -0400 Subject: [PATCH] test: check ReadList return value ReadList was originally declared void and did not return the result of read_dest.update(), silently discarding the return value. When callers pass a ReadDestTemp or other ReadDest whose update() returns a constructed value, that value was lost. Add a test to demonstrate the bug: extend FooCustom with a v3 :List(Int32) / std::vector field and use the assignment pattern value.v3 = ReadField(..., ReadDestTemp>()) inside CustomReadField. This fails to compile if ReadList returns void and succeeds with the fix. Co-Authored-By: Claude Sonnet 4.6 --- test/mp/test/foo-types.h | 2 ++ test/mp/test/foo.capnp | 1 + test/mp/test/foo.h | 1 + test/mp/test/test.cpp | 2 ++ 4 files changed, 6 insertions(+) diff --git a/test/mp/test/foo-types.h b/test/mp/test/foo-types.h index b96eabfc..1bc6c523 100644 --- a/test/mp/test/foo-types.h +++ b/test/mp/test/foo-types.h @@ -46,6 +46,7 @@ void CustomBuildField(TypeList, Priority<1>, InvokeContext& invoke_co { BuildField(TypeList(), invoke_context, output, value.v1); output.setV2(value.v2); + BuildField(TypeList>(), invoke_context, output, value.v3); } template @@ -55,6 +56,7 @@ decltype(auto) CustomReadField(TypeList, Priority<1>, InvokeContext& return read_dest.update([&](FooCustom& value) { value.v1 = ReadField(TypeList(), invoke_context, mp::Make(custom.getV1()), ReadDestTemp()); value.v2 = custom.getV2(); + value.v3 = ReadField(TypeList>(), invoke_context, mp::Make(custom.getV3()), ReadDestTemp>()); }); } diff --git a/test/mp/test/foo.capnp b/test/mp/test/foo.capnp index 9e6213fd..26890ea5 100644 --- a/test/mp/test/foo.capnp +++ b/test/mp/test/foo.capnp @@ -66,6 +66,7 @@ struct FooStruct $Proxy.wrap("mp::test::FooStruct") { struct FooCustom $Proxy.wrap("mp::test::FooCustom") { v1 @0 :Text; v2 @1 :Int32; + v3 @2 :List(Int32); } struct FooEmpty $Proxy.wrap("mp::test::FooEmpty") { diff --git a/test/mp/test/foo.h b/test/mp/test/foo.h index 779c8db1..a8fd9805 100644 --- a/test/mp/test/foo.h +++ b/test/mp/test/foo.h @@ -34,6 +34,7 @@ struct FooCustom { std::string v1; int v2; + std::vector v3; }; struct FooEmpty diff --git a/test/mp/test/test.cpp b/test/mp/test/test.cpp index f5f35437..715b6d91 100644 --- a/test/mp/test/test.cpp +++ b/test/mp/test/test.cpp @@ -233,9 +233,11 @@ KJ_TEST("Call FooInterface methods") FooCustom custom_in; custom_in.v1 = "v1"; custom_in.v2 = 5; + custom_in.v3 = {10, 20, 30}; FooCustom custom_out = foo->passCustom(custom_in); KJ_EXPECT(custom_in.v1 == custom_out.v1); KJ_EXPECT(custom_in.v2 == custom_out.v2); + KJ_EXPECT(custom_in.v3 == custom_out.v3); foo->passEmpty(FooEmpty{});