Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion compiler/noirc_evaluator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ petgraph.workspace = true

[dev-dependencies]
proptest.workspace = true
proptest-derive.workspace = true
similar-asserts.workspace = true
tracing-test = "0.2.5"
num-traits.workspace = true
Expand Down
27 changes: 26 additions & 1 deletion compiler/noirc_evaluator/src/ssa/ir/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use crate::ssa::ssa_gen::SSA_WORD_SIZE;
/// Fields do not have a notion of ordering, so this distinction
/// is reasonable.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize)]
#[cfg_attr(test, derive(proptest_derive::Arbitrary))]
pub enum NumericType {
Signed { bit_size: u32 },
Unsigned { bit_size: u32 },
Expand Down Expand Up @@ -101,6 +100,32 @@ impl NumericType {
}
}

#[cfg(test)]
mod props {
use proptest::{
prelude::{Arbitrary, BoxedStrategy, Just, Strategy as _},
prop_oneof,
};

use super::NumericType;

impl Arbitrary for NumericType {
type Parameters = ();
type Strategy = BoxedStrategy<Self>;

fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy {
let signed = prop_oneof!(Just(8), Just(16), Just(32), Just(64));
let unsigned = prop_oneof!(Just(1), Just(8), Just(16), Just(32), Just(64), Just(128));
prop_oneof![
signed.prop_map(|bit_size| NumericType::Signed { bit_size }),
unsigned.prop_map(|bit_size| NumericType::Unsigned { bit_size }),
Just(NumericType::NativeField),
]
.boxed()
}
}
}

/// All types representable in the IR.
#[derive(Clone, Debug, PartialEq, Eq, Hash, Ord, PartialOrd, Serialize, Deserialize)]
pub(crate) enum Type {
Expand Down
Loading