slint/internal/compiler/tests/syntax/lookup/for_lookup.slint
Tobias Hunger 4230ac2572
Update copyright information to reflect name change
Also run resue over the codebase and fix complaints from that tool.
2022-02-09 10:27:47 +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
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.
}
}