From 4639454a9fb82fe668a2f0af6c6997ba1f853d54 Mon Sep 17 00:00:00 2001 From: Edgar Luque Date: Thu, 16 Jan 2025 16:20:30 +0100 Subject: [PATCH 1/7] Remove missing todos --- src/bin/utils/mod.rs | 5 ++++- src/compiler.rs | 2 +- src/executor.rs | 4 ++-- src/libfuncs/const.rs | 2 +- src/libfuncs/int.rs | 3 ++- src/types/circuit.rs | 3 ++- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/bin/utils/mod.rs b/src/bin/utils/mod.rs index b4cce9a1f..160d647b5 100644 --- a/src/bin/utils/mod.rs +++ b/src/bin/utils/mod.rs @@ -134,7 +134,10 @@ fn jitvalue_to_felt(value: &Value) -> Vec { felts } } else { - todo!() + // Assume its a regular enum. + let mut felts = vec![(*tag).into()]; + felts.extend(jitvalue_to_felt(value)); + felts } } Value::Felt252Dict { value, .. } => { diff --git a/src/compiler.rs b/src/compiler.rs index d7c35f235..eacf806eb 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -758,7 +758,7 @@ fn compile_func( } }) .collect::, _>>()?, - None => todo!(), + None => native_panic!("should be Some always"), }; block.append_operation(cf::cond_br( diff --git a/src/executor.rs b/src/executor.rs index 8aaf2d9fe..994ffa228 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -635,9 +635,9 @@ fn parse_result( | CoreTypeConcrete::StarkNet(_) | CoreTypeConcrete::Uint128MulGuarantee(_) | CoreTypeConcrete::Circuit(_) - | CoreTypeConcrete::RangeCheck96(_) => todo!(), + | CoreTypeConcrete::RangeCheck96(_) => native_panic!("not yet implemented as results"), // 2.9.0 - CoreTypeConcrete::IntRange(_) => todo!(), + CoreTypeConcrete::IntRange(_) => native_panic!("not yet implemented as results"), } } diff --git a/src/libfuncs/const.rs b/src/libfuncs/const.rs index fa4e1892b..dc438201f 100644 --- a/src/libfuncs/const.rs +++ b/src/libfuncs/const.rs @@ -284,7 +284,7 @@ pub fn build_const_type_value<'ctx, 'this>( } _ => Err(Error::ConstDataMismatch), }, - _ => todo!("const for type {}", info.inner_ty), + _ => native_panic!("const for type {} not implemented", info.inner_ty), } } diff --git a/src/libfuncs/int.rs b/src/libfuncs/int.rs index 58f3a4d9d..82f2b6e4d 100644 --- a/src/libfuncs/int.rs +++ b/src/libfuncs/int.rs @@ -2,6 +2,7 @@ use super::{BlockExt, LibfuncHelper}; use crate::{ error::Result, metadata::MetadataStorage, + native_panic, types::TypeBuilder, utils::{ProgramRegistryExt, PRIME}, }; @@ -636,7 +637,7 @@ fn build_square_root<'ctx, 'this>( CoreTypeConcrete::Uint32(_) => (32, 16), CoreTypeConcrete::Uint64(_) => (64, 32), CoreTypeConcrete::Uint128(_) => (128, 64), - _ => unreachable!(), + _ => native_panic!("unhandled type in int square root"), }; let k1 = entry.const_int(context, location, 1, input_bits)?; diff --git a/src/types/circuit.rs b/src/types/circuit.rs index 467e86956..6c3c96d3a 100644 --- a/src/types/circuit.rs +++ b/src/types/circuit.rs @@ -6,6 +6,7 @@ use super::WithSelf; use crate::{ error::{Result, SierraAssertError}, metadata::MetadataStorage, + native_panic, utils::{get_integer_layout, layout_repeat}, }; use cairo_lang_sierra::{ @@ -280,7 +281,7 @@ pub fn layout( Ok(layout) } CircuitTypeConcrete::CircuitPartialOutputs(_) => { - todo!("CircuitPartialOutputs is noop for now") + native_panic!("CircuitPartialOutputs is noop for now"); } } } From e5cbf13d1ecf4731c8640c5fac8248bc947d5a2d Mon Sep 17 00:00:00 2001 From: Edgar Date: Thu, 16 Jan 2025 17:49:06 +0100 Subject: [PATCH 2/7] Update src/compiler.rs Co-authored-by: MrAzteca --- src/compiler.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler.rs b/src/compiler.rs index eacf806eb..a36b19589 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -758,7 +758,7 @@ fn compile_func( } }) .collect::, _>>()?, - None => native_panic!("should be Some always"), + None => native_panic!("not yet implemented"), }; block.append_operation(cf::cond_br( From b1bc0d1fd7b778d29d53eca3a9455041c2dbc1a3 Mon Sep 17 00:00:00 2001 From: Edgar Date: Fri, 17 Jan 2025 15:12:03 +0100 Subject: [PATCH 3/7] Update src/types/circuit.rs Co-authored-by: MrAzteca --- src/types/circuit.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/circuit.rs b/src/types/circuit.rs index 6c3c96d3a..acd7a2450 100644 --- a/src/types/circuit.rs +++ b/src/types/circuit.rs @@ -281,7 +281,7 @@ pub fn layout( Ok(layout) } CircuitTypeConcrete::CircuitPartialOutputs(_) => { - native_panic!("CircuitPartialOutputs is noop for now"); + Ok(Layout::new::<()>()) } } } From 1ef0d5f7e732655b4df0709a154f561cc005d761 Mon Sep 17 00:00:00 2001 From: Edgar Date: Fri, 17 Jan 2025 15:12:13 +0100 Subject: [PATCH 4/7] Update src/libfuncs/int.rs Co-authored-by: MrAzteca --- src/libfuncs/int.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libfuncs/int.rs b/src/libfuncs/int.rs index 82f2b6e4d..4cd9732a4 100644 --- a/src/libfuncs/int.rs +++ b/src/libfuncs/int.rs @@ -637,7 +637,7 @@ fn build_square_root<'ctx, 'this>( CoreTypeConcrete::Uint32(_) => (32, 16), CoreTypeConcrete::Uint64(_) => (64, 32), CoreTypeConcrete::Uint128(_) => (128, 64), - _ => native_panic!("unhandled type in int square root"), + _ => native_panic!("invalid value type in int square root"), }; let k1 = entry.const_int(context, location, 1, input_bits)?; From b7dfd1c55555409216f35f1402a6a9a7aa288680 Mon Sep 17 00:00:00 2001 From: Edgar Luque Date: Mon, 20 Jan 2025 09:58:41 +0100 Subject: [PATCH 5/7] fmt --- src/types/circuit.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/types/circuit.rs b/src/types/circuit.rs index acd7a2450..b98b0947e 100644 --- a/src/types/circuit.rs +++ b/src/types/circuit.rs @@ -280,8 +280,6 @@ pub fn layout( Ok(layout) } - CircuitTypeConcrete::CircuitPartialOutputs(_) => { - Ok(Layout::new::<()>()) - } + CircuitTypeConcrete::CircuitPartialOutputs(_) => Ok(Layout::new::<()>()), } } From 0022d144da47e918dd9cbde159832e35e4c71186 Mon Sep 17 00:00:00 2001 From: Edgar Luque Date: Mon, 20 Jan 2025 11:39:18 +0100 Subject: [PATCH 6/7] clippy --- src/types/circuit.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/types/circuit.rs b/src/types/circuit.rs index b98b0947e..b8b9c93a4 100644 --- a/src/types/circuit.rs +++ b/src/types/circuit.rs @@ -6,7 +6,6 @@ use super::WithSelf; use crate::{ error::{Result, SierraAssertError}, metadata::MetadataStorage, - native_panic, utils::{get_integer_layout, layout_repeat}, }; use cairo_lang_sierra::{ From 67a9f68c0b9ef16da53f667a2c77daf7be0594e3 Mon Sep 17 00:00:00 2001 From: Edgar Luque Date: Wed, 22 Jan 2025 15:03:26 +0100 Subject: [PATCH 7/7] fix --- src/libfuncs/const.rs | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/libfuncs/const.rs b/src/libfuncs/const.rs index 105992726..a13622833 100644 --- a/src/libfuncs/const.rs +++ b/src/libfuncs/const.rs @@ -269,23 +269,22 @@ pub fn build_const_type_value<'ctx, 'this>( entry.const_int_from_type(context, location, value, inner_ty) } - CoreTypeConcrete::StarkNet(starnet_type) => match starnet_type { - StarkNetTypeConcrete::ClassHash(_) | StarkNetTypeConcrete::ContractAddress(_) => { - let value = match &info.inner_data.as_slice() { - [GenericArg::Value(value)] => value.clone(), - _ => return Err(Error::ConstDataMismatch), - }; + CoreTypeConcrete::StarkNet( + StarkNetTypeConcrete::ClassHash(_) | StarkNetTypeConcrete::ContractAddress(_), + ) => { + let value = match &info.inner_data.as_slice() { + [GenericArg::Value(value)] => value.clone(), + _ => return Err(Error::ConstDataMismatch), + }; - let (sign, value) = value.into_parts(); - let value = match sign { - Sign::Minus => PRIME.clone() - value, - _ => value, - }; + let (sign, value) = value.into_parts(); + let value = match sign { + Sign::Minus => PRIME.clone() - value, + _ => value, + }; - entry.const_int_from_type(context, location, value, inner_ty) - } - _ => native_panic!("const for type {} not implemented", info.inner_ty), - }, + entry.const_int_from_type(context, location, value, inner_ty) + } CoreTypeConcrete::Uint8(_) | CoreTypeConcrete::Uint16(_) | CoreTypeConcrete::Uint32(_)