CQCL / hugr

Hierarchical Unified Graph Representation for quantum and classical programs
https://crates.io/crates/hugr
Apache License 2.0
18 stars 5 forks source link

In serialisation we do not distinguish between unknown `CustomConst` serialised value invalid but known `CustomConst` serialised values #1225

Open doug-q opened 3 months ago

doug-q commented 3 months ago

We use the typetag crate to manage serialisation and deserialisation of dyn CustomConst values. When deserialisation of a dyn CustomConst fails, we are not able to distinguish between: 1) The impl CustomConst is not linked into the current program, so the typetag handler for that type is not present 2) The serialisation of the known impl CustomConst was invalid. (e.g. see https://github.com/CQCL/hugr/issues/1091)

Currently we do not fail to deserialise, and store a CustomSerialized in the Hugr.

We should fail to deserialise in the 2) case, and continue to succeed with a CustomSerialized in the 1) case.

typetag does not offer any facility to distinguish these cases. I see three options:

doug-q commented 3 months ago

See https://github.com/dtolnay/typetag/issues/79