Skip to content

Commit

Permalink
check for never types in arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
xunilrj committed Aug 13, 2024
1 parent da097a5 commit 6f7fda5
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions sway-core/src/language/ty/expression/expression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,23 @@ impl TypeCheckAnalysis for TyExpression {
elem_type,
contents,
} => {
for element in contents {
let array_elem_type = ctx.engines.te().get(*elem_type);
if !matches!(&*array_elem_type, TypeInfo::Never) {
let unify = crate::type_system::unify::unifier::Unifier::new(
ctx.engines,
"",
unify::unifier::UnifyKind::Default,
);
unify.unify(handler, element.return_type, *elem_type, &element.span)
for element in contents {
let element_type = ctx.engines.te().get(*elem_type);

// If the element is never, we do not need to check
if matches!(&*element_type, TypeInfo::Never) {
continue;
}

unify.unify(handler, element.return_type, *elem_type, &element.span)
}
}
}
_ => {}
Expand Down

0 comments on commit 6f7fda5

Please sign in to comment.