Skip to content

Commit

Permalink
Merge 758d70f into 3bceb0a
Browse files Browse the repository at this point in the history
  • Loading branch information
esdrubal authored Aug 23, 2024
2 parents 3bceb0a + 758d70f commit e8f1d05
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 16 deletions.
38 changes: 22 additions & 16 deletions sway-core/src/semantic_analysis/ast_node/declaration/impl_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -831,22 +831,28 @@ fn type_check_trait_implementation(
None,
),
};
trait_type_mapping.extend(&TypeSubstMap::from_type_parameters_and_type_arguments(
vec![type_engine.insert(
engines,
old_type_decl_info1,
type_decl.name.span().source_id(),
)],
vec![type_decl.ty.clone().unwrap().type_id],
));
trait_type_mapping.extend(&TypeSubstMap::from_type_parameters_and_type_arguments(
vec![type_engine.insert(
engines,
old_type_decl_info2,
type_decl.name.span().source_id(),
)],
vec![type_decl.ty.clone().unwrap().type_id],
));
if let Some(type_arg) = type_decl.ty.clone() {
trait_type_mapping.extend(
&TypeSubstMap::from_type_parameters_and_type_arguments(
vec![type_engine.insert(
engines,
old_type_decl_info1,
type_decl.name.span().source_id(),
)],
vec![type_arg.type_id],
),
);
trait_type_mapping.extend(
&TypeSubstMap::from_type_parameters_and_type_arguments(
vec![type_engine.insert(
engines,
old_type_decl_info2,
type_decl.name.span().source_id(),
)],
vec![type_arg.type_id],
),
);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[[package]]
name = "associated_type_not_in_trait"
source = "member"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[project]
authors = ["Fuel Labs <contact@fuel.sh>"]
entry = "main.sw"
license = "Apache-2.0"
name = "associated_type_not_in_trait"
implicit-std = false
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
script;
trait Trait{}
struct Struct0{}
impl Trait for Struct0{type u;const u=0;}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
category = "fail"

# check: $()Type "u" is not a part of trait "Trait"'s interface surface.

0 comments on commit e8f1d05

Please sign in to comment.