1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3
4component Foo /* Foo 1 */ { }
5
6export component FooBaz {
7 Foo /* <- TEST_ME_1 */ { }
8}
9
10component Foo /* Foo 2 */ { }
11// ^warning{Component 'Foo' is replacing a previously defined component with the same name}
12
13export component Baz {
14 Foo /* <- TEST_ME_2 */ { }
15}
16
17
18struct Type1 { xxx: int }
19enum Type2 { AAA, BBB }
20
21 component Test1 {}
22//^warning{Component is neither used nor exported}
23
24export component Test1 {
25// ^warning{Component 'Test1' is replacing a previously defined component with the same name}
26 property <Type1> t1: { xxx: 42 };
27 property <Type2> t2: Type2.AAA;
28// ^error{Cannot access id 'Type2'} // because in the lookup phase it was already erased
29
30 init => {
31 debug(Type1.CCC); // This is allowed because the resolving phase has full view on the document
32 debug(Type2.AAA);
33// ^error{Cannot access id 'Type2'}
34 }
35}
36
37struct Type2 { yyy: int }
38// ^warning{Struct 'Type2' is replacing a previously defined type with the same name}
39enum Type1 { CCC, DDD }
40// ^warning{Enum 'Type1' is replacing a previously defined type with the same name}
41export component Test2 {
42 property <Type1> t1: Type1.DDD;
43 property <Type2> t2: { yyy: 42 };
44 property <Type1> error: Type2.AAA;
45 // ^error{Cannot access id 'Type2'}
46}
47
48