mirror of
https://github.com/slint-ui/slint.git
synced 2025-07-24 13:35:00 +00:00
Fix conversions of array literal containing struct with array literal
Fixes #2023
This commit is contained in:
parent
8edc7f669a
commit
8d7b8df922
3 changed files with 22 additions and 3 deletions
|
@ -1075,15 +1075,17 @@ impl Expression {
|
|||
},
|
||||
};
|
||||
Expression::Cast { from: Box::new(from), to: target_type }
|
||||
} else if matches!((&ty, &target_type, &self), (Type::Array(left), Type::Array(right), Expression::Array{..})
|
||||
if left.can_convert(right) || **left == Type::Invalid)
|
||||
{
|
||||
} else if matches!(
|
||||
(&ty, &target_type, &self),
|
||||
(Type::Array(_), Type::Array(_), Expression::Array { .. })
|
||||
) {
|
||||
// Special case for converting array literals
|
||||
match (self, target_type) {
|
||||
(Expression::Array { values, .. }, Type::Array(target_type)) => Expression::Array {
|
||||
values: values
|
||||
.into_iter()
|
||||
.map(|e| e.maybe_convert_to((*target_type).clone(), node, diag))
|
||||
.take_while(|e| !matches!(e, Expression::Invalid))
|
||||
.collect(),
|
||||
element_ty: *target_type,
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue