diff --git a/internal/compiler/expression_tree.rs b/internal/compiler/expression_tree.rs index ec518ebe3e..d07f6c2197 100644 --- a/internal/compiler/expression_tree.rs +++ b/internal/compiler/expression_tree.rs @@ -1059,8 +1059,8 @@ impl Expression { op: '*', }, ( - Type::Struct { fields: ref left, .. }, - Type::Struct { fields: right, name, node: n, rust_attributes }, + ref from_ty @ Type::Struct { fields: ref left, .. }, + Type::Struct { fields: right, .. }, ) if left != right => { if let Expression::Struct { mut values, .. } = self { let mut new_values = HashMap::new(); @@ -1080,12 +1080,7 @@ impl Expression { Expression::StructFieldAccess { base: Box::new(Expression::ReadLocalVariable { name: var_name.into(), - ty: Type::Struct { - fields: left.clone(), - name: name.clone(), - node: n.clone(), - rust_attributes: rust_attributes.clone(), - }, + ty: from_ty.clone(), }), name: key.clone(), } diff --git a/tests/cases/types/structs2.slint b/tests/cases/types/structs2.slint index 4c84ad81c8..e4aab829ab 100644 --- a/tests/cases/types/structs2.slint +++ b/tests/cases/types/structs2.slint @@ -7,9 +7,14 @@ struct Foo1 { member: int, } struct Foo2 { a: Foo1 } struct Foo3 { b: int } - struct DeleteMe { c: color } +struct Palette { + menuBar : brush, + mainContent : brush, + box : brush, +} + export component TestCase inherits Rectangle { pure callback cb1(Foo2) -> Foo3; cb1(foo) => { return { b: foo.a.member+1 }; } @@ -24,6 +29,18 @@ export component TestCase inherits Rectangle { property<[DeleteMe]> data; for d[i] in self.data: Rectangle { } } + + // Bug #2765 + out property palette : xx.a.member > 32 ? { + menuBar : #6D7BFB, + mainContent : #fbfbfb, + box : #ffffff, + } : { + menuBar : #2937A7, + mainContent : #040404, + box : #000000, + }; + }