Skip to content

Commit

Permalink
return type checked trait constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
xunilrj committed Oct 24, 2024
1 parent cc842e3 commit 4c6ca5b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions sway-core/src/type_system/ast_elements/type_parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl TypeParameter {
// Type check trait constraints only after type checking all type parameters.
// This is required because a trait constraint may use other type parameters.
// Ex: `struct Struct2<A, B> where A : MyAdd<B>`
for type_param in &new_type_params {
for type_param in new_type_params.iter_mut() {
TypeParameter::type_check_trait_constraints(handler, ctx.by_ref(), type_param)?;
}

Expand Down Expand Up @@ -327,7 +327,7 @@ impl TypeParameter {
fn type_check_trait_constraints(
handler: &Handler,
mut ctx: TypeCheckContext,
type_parameter: &TypeParameter,
type_parameter: &mut TypeParameter,
) -> Result<(), ErrorEmitted> {
let type_engine = ctx.engines.te();

Expand Down Expand Up @@ -372,6 +372,8 @@ impl TypeParameter {
},
);

type_parameter.trait_constraints = trait_constraints_with_supertraits;

// Insert the trait constraints into the namespace.
type_parameter.insert_into_namespace_constraints(handler, ctx.by_ref())?;

Expand Down

0 comments on commit 4c6ca5b

Please sign in to comment.