You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PHIR classical registers with size 0 are accepted outside the schema and silently zero or sign-fill writes #1348
A classical register declared with "size": 0 is accepted by every PHIR path that does not run the pydantic schema. Writes into it then give silently wrong values. The upstream PHIR schema (size: PositiveInt | None), and so PhirModel.model_validate, rejects the declaration.
Reproduction
The native results below come from the #1314 branch. The size handling involved is the same on dev: Environment::validate_variable_size in crates/pecos-phir-json/src/v0_1/environment.rs (~578 on dev) has no zero check.
a = 5 silently becomes 0 for unsigned registers. For signed registers it becomes -1: a signed size-S register is i(S+1), so size 0 keeps only the sign bit. A measurement into a[0] does fail, with "out of range for a register of declared size 0". The JSON-to-module converter was not checked.
Direction
Reject a classical size of 0 in the shared declaration validation, so every path agrees with the schema. Use a named error ("use a positive integer size that fits the data type"). Add a parity test over native, both interpreters (validation on and off) and the converter. The quantum side already rejects size 0.
Activity