Skip to content

Commit 02365e1

Browse files
nirvdrumtekknolagi
authored andcommitted
ZJIT: Assert we never try to get the byte size of an Empty value
An `Empty` value has no representable size. The caller trying to get the size is operating on an unreachable instruction that should have already been removed.
1 parent 1cd2c5d commit 02365e1

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

zjit/src/hir_type/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,9 @@ impl Type {
593593
}
594594

595595
pub fn num_bytes(&self) -> u8 {
596+
assert!(!self.bit_equal(types::Empty),
597+
"a value of type Empty is unreachable and should have been eliminated before codegen");
598+
596599
if self.is_subtype(types::CUInt8) || self.is_subtype(types::CInt8) { return 1; }
597600
if self.is_subtype(types::CUInt16) || self.is_subtype(types::CInt16) { return 2; }
598601
if self.is_subtype(types::CUInt32) || self.is_subtype(types::CInt32) { return 4; }

0 commit comments

Comments
 (0)