From b9f13d48aa7e2c0652210152b971b21c3c419347 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Mon, 19 Dec 2022 00:57:46 +0000 Subject: [PATCH] firmware: Fix object references in tuples Sine 8740ec3dd, the alignment() information from "run-time type information" (i.e. the Tag type) is also used when sending tuples to the host. --- artiq/firmware/libproto_artiq/rpc_proto.rs | 4 ++-- artiq/test/coredevice/test_embedding.py | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/artiq/firmware/libproto_artiq/rpc_proto.rs b/artiq/firmware/libproto_artiq/rpc_proto.rs index 85fc902ba..49b78e633 100644 --- a/artiq/firmware/libproto_artiq/rpc_proto.rs +++ b/artiq/firmware/libproto_artiq/rpc_proto.rs @@ -429,8 +429,8 @@ mod tag { // the ptr/length(s) pair is basically CSlice Tag::Bytes | Tag::String | Tag::ByteArray | Tag::List(_) | Tag::Array(_, _) => core::mem::align_of::>(), - // will not be sent from the host - _ => unreachable!("unexpected tag from host") + Tag::Keyword(_) => unreachable!("Tag::Keyword should not appear in composite types"), + Tag::Object => core::mem::align_of::(), } } diff --git a/artiq/test/coredevice/test_embedding.py b/artiq/test/coredevice/test_embedding.py index 537cec113..807bc4896 100644 --- a/artiq/test/coredevice/test_embedding.py +++ b/artiq/test/coredevice/test_embedding.py @@ -74,6 +74,9 @@ class RoundtripTest(ExperimentCase): def test_object_list(self): self.assertRoundtrip([object(), object()]) + def test_object_tuple(self): + self.assertRoundtrip((False, object(), True, 0x12345678)) + def test_list_tuple(self): self.assertRoundtrip(([1, 2], [3, 4]))