diff --git a/crates/cairo-lang-semantic/src/corelib.rs b/crates/cairo-lang-semantic/src/corelib.rs index 925f8ec762d..797d75128f7 100644 --- a/crates/cairo-lang-semantic/src/corelib.rs +++ b/crates/cairo-lang-semantic/src/corelib.rs @@ -181,7 +181,7 @@ pub fn try_get_ty_by_name<'db>( } _ => GenericTypeId::option_from(module_item_id), } - .unwrap_or_else(|| panic!("{} is not a type.", name.long(db))); + .ok_or(SemanticDiagnosticKind::NotAType)?; Ok(semantic::TypeLongId::Concrete(semantic::ConcreteTypeId::new( db, diff --git a/crates/cairo-lang-semantic/src/expr/test_data/literal b/crates/cairo-lang-semantic/src/expr/test_data/literal index f12b90b3e69..0ffe8a601e9 100644 --- a/crates/cairo-lang-semantic/src/expr/test_data/literal +++ b/crates/cairo-lang-semantic/src/expr/test_data/literal @@ -16,3 +16,24 @@ error[E2008]: A numeric literal of type core::pedersen::Pedersen cannot be creat --> lib.cairo:2:14 let _a = 'a'_Pedersen; ^^^^^^^^^^^^ + +//! > ========================================================================== + +//! > Numeric literal with a non-type suffix. + +//! > test_runner_name +test_function_diagnostics(expect_diagnostics: true) + +//! > function_code +fn foo() { + let _x = 1_boolean; +} + +//! > function_name +foo + +//! > expected_diagnostics +error[E2011]: Not a type. + --> lib.cairo:2:14 + let _x = 1_boolean; + ^^^^^^^^^