{"record":{"id":"3b8337699cc9dac9","repo":"pydantic/monty","slug":"usize-fits-in-u128","errorCode":null,"errorMessage":"usize fits in u128","messagePattern":"usize fits in u128","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/monty/src/identity.rs","lineNumber":104,"sourceCode":"    }\n\n    /// Builds the identity of an arena-allocated object.\n    pub(crate) fn from_heap_id(id: HeapId) -> Self {\n        Self::Heap(id.index())\n    }\n\n    /// Encodes this key as the nonnegative integer exposed by Python's `id()`.\n    pub(crate) fn encoded(&self) -> u128 {\n        let payload = match self {\n            Self::Undefined | Self::Ellipsis | Self::NotImplemented | Self::None => 0,\n            Self::Bool(value) => u128::from(*value),\n            Self::Int(value) => u128::from(zigzag_i64(*value)),\n            Self::Float(bits) => u128::from(compact_float_bits(*bits)),\n            Self::InternString(index)\n            | Self::InternBytes(index)\n            | Self::InternLongInt(index)\n            | Self::DefFunction(index)\n            | Self::Heap(index) => u128::try_from(*index).expect(\"usize fits in u128\"),\n            Self::Builtin(value) => fixed_serde_payload(value),\n            Self::ModuleFunction(value) => fixed_serde_payload(value),\n            Self::Marker(value) => fixed_serde_payload(value),\n            Self::Property(value) => fixed_serde_payload(value),\n        };\n        (payload << TAG_BITS) | u128::from(self.tag())\n    }\n\n    /// Encodes this key as a Python integer.\n    ///\n    /// Returns an immediate integer when possible, otherwise allocating a `LongInt`.\n    pub(crate) fn into_value(self, heap: &Heap) -> Value {\n        LongInt::value_from_u128(self.encoded(), heap)\n    }\n\n    /// Returns the stable low-bit category tag for this identity variant.\n    fn tag(&self) -> u8 {\n        match self {","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/pydantic/monty/blob/adc986b362e3961f407868cb118a99fe831b9e61/crates/monty/src/identity.rs#L86-L122","documentation":"An internal invariant `expect` in `ObjectIdentity::encoded`, the implementation behind Python's `id()`. The identity payload is accumulated into a `u128` from components (heap index, zigzagged int, float bits, byte payloads), and the assertion states that a `usize` heap index always fits in the 128-bit accumulator — trivially true on every supported platform. It fires only if the invariant is violated, i.e. never in correct builds; there is no user-controllable input that can trigger it.","triggerScenarios":"Thrown at crates/monty/src/identity.rs:104 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["This expect fires only if a usize exceeds u128, impossible on all supported targets since usize is at most 64 bits; no recovery needed and none is possible.","If it ever fires, it indicates a compile-target assumption violation: audit the platform's usize width and the encoded() layout rather than handling at runtime."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"adc986b362e3961f407868cb118a99fe831b9e61","analyzedAt":"2026-09-13T19:19:18.698Z","contentChangedAt":"2026-09-13T19:19:18.698Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}