slint/internal/compiler/tests/syntax/lookup/for_lookup.slint
Simon Hausmann 24dcef5fed
First stage of cleaning up the export handling of the slint root component (#2095)
We implicitly export the last component of a .slint file to the generator.
Issue a warning when that happens and suggest to export it explicitly.
2023-01-23 15:19:49 +01:00

70 lines
1.7 KiB
Text

// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial
export Hello := Rectangle {
aaa := Text{ text: "aaa";
bbb := Text{ text: "bbb"; }
}
property<int> count: 5;
for foo[idx] in count: Rectangle {
x: idx * 1phx;
ccc := Text {
x: idx * 1phx;
text: aaa.text;
y: foo * 1phx;
}
}
for gre[mem] in err: Rectangle {
//^error{Unknown unqualified identifier 'err'}
x: mem * 1phx;
ddd := Text { text: ccc.text; }
// ^error{Cannot access id 'ccc'}
}
for plop in 0 : named_for := Rectangle {
Text { color: named_for.background; }
}
Text {
text: ccc.text;
// ^error{Cannot access id 'ccc'}
color: named_for.background;
// ^error{Cannot access id 'named_for'}
}
for aaa in aaa.text: Rectangle {
// ^error{Cannot convert string to model}
}
for plop in [1,2,3,4]: Rectangle {
x: plop * 1phx;
Rectangle {
background: plop;
// ^error{Cannot convert float to brush}
}
}
for pp[idx] in [1,3,2]: Rectangle {
x: idx * 1phx;
y: 25phx * pp;
}
for pp[idx] in [{a: 1phx, b: "P"},{a: 2phx, b: "Q"}]: Text {
x: pp.a;
text: pp.b;
y: pp.b;
// ^error{Cannot convert string to length}
property<int> ggg: pp;
// ^error{Cannot convert \{ a: physical-length,b: string,\} to int}
}
for pp[idx] in [{a: 1, b: "P"},{a: 2, c: 1}]: Text {
text: pp.b; // Ok! pp will have a, b and c properties, and b will be the empty string.
}
}