Skip to content

Commit

Permalink
Removed no longer relevant assertion. (#7162)
Browse files Browse the repository at this point in the history
  • Loading branch information
orizi authored Jan 27, 2025
1 parent 42c370c commit 74e6adb
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 9 deletions.
12 changes: 3 additions & 9 deletions crates/cairo-lang-semantic/src/expr/inference.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1230,15 +1230,9 @@ impl SemanticRewriter<TypeLongId, NoError> for Inference<'_> {
let impl_id = impl_type_id.impl_id();
let trait_ty = impl_type_id.ty();
return Ok(match impl_id.lookup_intern(self.db) {
ImplLongId::GenericParameter(_) | ImplLongId::SelfImpl(_) => {
impl_type_id_rewrite_result
}
ImplLongId::ImplImpl(impl_impl) => {
// The grand parent impl must be var free since we are rewriting the parent,
// and the parent is not var.
assert!(impl_impl.impl_id().is_var_free(self.db));
impl_type_id_rewrite_result
}
ImplLongId::GenericParameter(_)
| ImplLongId::SelfImpl(_)
| ImplLongId::ImplImpl(_) => impl_type_id_rewrite_result,
ImplLongId::Concrete(_) => {
if let Ok(ty) = self.db.impl_type_concrete_implized(ImplTypeId::new(
impl_id, trait_ty, self.db,
Expand Down
61 changes: 61 additions & 0 deletions crates/cairo-lang-semantic/src/items/tests/trait_impl
Original file line number Diff line number Diff line change
Expand Up @@ -1367,3 +1367,64 @@ error: Trait has no implementation in context: core::metaprogramming::TypeEqual:
--> lib.cairo:31:11
1_u64.foo(1_u32);
^^^

//! > ==========================================================================

//! > Trait default implementation with recursive types.

//! > test_runner_name
test_function_diagnostics(expect_diagnostics: true)

//! > function
fn foo() {
// TODO(orizi): Remove this diagnostic.
mix(1_u64.into_inner(), 1_u32.into_inner());
}

//! > function_name
foo

//! > module_code
trait Outer<T> {
type Inner;
impl Impl: Inner<Self::Inner>;
fn into_inner(self: T) -> Self::Inner;
}

trait Inner<T> {
type InnerMost;
}

fn mix<
T,
U,
impl InnerT: Inner<T>,
impl OuterU: Outer<U>,
+core::metaprogramming::TypeEqual<InnerT::InnerMost, OuterU::Impl::InnerMost>,
>(
lhs: T, rhs: U,
) {}

impl OuterU32 of Outer<u32> {
type Inner = u64;
fn into_inner(self: u32) -> u64 {
self.into()
}
}

impl OuterU64 of Outer<u64> {
type Inner = u64;
fn into_inner(self: u64) -> u64 {
self
}
}

impl InnerImpl of Inner<u64> {
type InnerMost = u128;
}

//! > expected_diagnostics
error: Impl mismatch: `Outer::Impl` and `test::InnerImpl`.
--> lib.cairo:40:5
mix(1_u64.into_inner(), 1_u32.into_inner());
^^^

0 comments on commit 74e6adb

Please sign in to comment.