From b74a304bad6e24853a4ab0818b1284af8b20b23f Mon Sep 17 00:00:00 2001 From: xunilrj Date: Fri, 18 Aug 2023 08:31:49 +0100 Subject: [PATCH] const_eval asserts --- sway-core/src/ir_generation/const_eval.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sway-core/src/ir_generation/const_eval.rs b/sway-core/src/ir_generation/const_eval.rs index 36b64bd1070..bedc159d554 100644 --- a/sway-core/src/ir_generation/const_eval.rs +++ b/sway-core/src/ir_generation/const_eval.rs @@ -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) { @@ -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");