Skip to content

Commit d186e14

Browse files
committed
chore: add regression test for #9986
1 parent 46df8f0 commit d186e14

4 files changed

Lines changed: 15 additions & 0 deletions

File tree

compiler/noirc_evaluator/src/ssa/ir/dfg/simplify/cast.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub(super) fn simplify_cast(
1717
dfg: &mut DataFlowGraph,
1818
) -> SimplifyResult {
1919
use SimplifyResult::*;
20+
debug_assert!(dfg.type_of_value(value).is_numeric(), "Can only cast numeric types, got {:?}", dfg.type_of_value(value));
2021

2122
if Type::Numeric(dst_typ) == dfg.type_of_value(value) {
2223
return SimplifiedTo(value);

compiler/noirc_evaluator/src/ssa/ir/types.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ impl Type {
191191
Type::unsigned(SSA_WORD_SIZE)
192192
}
193193

194+
/// True if this type is a numeric primitive type.
195+
pub(crate) fn is_numeric(&self) -> bool {
196+
matches!(self, Type::Numeric(_))
197+
}
198+
194199
/// Returns the inner NumericType if this is one, or panics otherwise
195200
pub(crate) fn unwrap_numeric(&self) -> NumericType {
196201
match self {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "regression_9986"
3+
type = "bin"
4+
authors = [""]
5+
6+
[dependencies]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
[("", 0_u32)][2147483648].1 == 0;
3+
}c

0 commit comments

Comments
 (0)