Skip to content

Commit

Permalink
const_eval asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
xunilrj committed Aug 21, 2023
1 parent dd42673 commit b74a304
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sway-core/src/ir_generation/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,8 +796,11 @@ fn const_eval_intrinsic(
}
}
Intrinsic::Lsh | Intrinsic::Rsh => {
assert!(args.len() == 2);
assert!(args[0].ty.is_uint(lookup.context));
assert!(args[1].ty.is_uint64(lookup.context));

let ty = args[0].ty;
assert!(args.len() == 2 && args[1].ty.is_uint64(lookup.context));

use ConstantValue::*;
match (&args[0].value, &args[1].value) {
Expand Down Expand Up @@ -940,10 +943,11 @@ fn const_eval_intrinsic(
span: intrinsic.span.clone(),
}),
Intrinsic::Not => {
// Not works only with uint/u256 at the moment
// `not` works only with uint/u256 at the moment
// `bool` ops::Not implementation uses `__eq`.

assert!(args.len() == 1);
assert!(args[0].ty.is_uint(lookup.context));

let Some(arg) = args.into_iter().next() else {
unreachable!("Unexpected 'not' without any arguments");
Expand Down

0 comments on commit b74a304

Please sign in to comment.