diff --git a/tamer/src/ir/asg/ident.rs b/tamer/src/ir/asg/ident.rs index f7ee9ad5..4f5dc9f1 100644 --- a/tamer/src/ir/asg/ident.rs +++ b/tamer/src/ir/asg/ident.rs @@ -347,7 +347,10 @@ pub struct Dim(u8); impl Dim { pub fn from_u8(value: u8) -> Self { - // TODO: 0≤n<10 + // We don't expect to format a value this large. + // In practice, it should never exceed 2. + assert!(value < 10, "Dim value cannot exceed 9"); + Self(value) } } diff --git a/tamer/src/ir/asg/object.rs b/tamer/src/ir/asg/object.rs index 33fbe297..1c93fcde 100644 --- a/tamer/src/ir/asg/object.rs +++ b/tamer/src/ir/asg/object.rs @@ -1022,7 +1022,7 @@ mod test { #[test] fn redeclare_compatible_resolves() { let sym: SymbolId = "extern_re_pre".intern(); - let kind = IdentKind::Class(Dim::from_u8(10)); + let kind = IdentKind::Class(Dim::from_u8(2)); let src = Source { desc: Some("okay".into()), ..Default::default() @@ -1040,7 +1040,7 @@ mod test { #[test] fn redeclare_compatible_resolves_post() { let sym: SymbolId = "extern_re_post".intern(); - let kind = IdentKind::Class(Dim::from_u8(10)); + let kind = IdentKind::Class(Dim::from_u8(1)); let src = Source { desc: Some("okay".into()), ..Default::default() @@ -1057,7 +1057,7 @@ mod test { #[test] fn redeclare_another_extern() { let sym: SymbolId = "extern_extern".intern(); - let kind = IdentKind::Class(Dim::from_u8(20)); + let kind = IdentKind::Class(Dim::from_u8(0)); let src_first = Source { desc: Some("first src".into()), ..Default::default() @@ -1083,7 +1083,7 @@ mod test { #[test] fn redeclare_post_incompatible_kind() { let sym: SymbolId = "extern_re_bad_post".intern(); - let kind = IdentKind::Class(Dim::from_u8(10)); + let kind = IdentKind::Class(Dim::from_u8(2)); let src = Source { desc: Some("bad kind".into()), ..Default::default() @@ -1127,7 +1127,7 @@ mod test { #[test] fn redeclare_pre_incompatible_kind() { let sym: SymbolId = "extern_re_bad_pre".intern(); - let kind_given = IdentKind::Class(Dim::from_u8(10)); + let kind_given = IdentKind::Class(Dim::from_u8(1)); let src = Source { desc: Some("bad kind".into()), ..Default::default()