| 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 | |
| 4 | export Hello := Rectangle { |
| 5 | |
| 6 | aaa := Text{ text: "aaa" ; |
| 7 | bbb := Text{ text: "bbb" ; } |
| 8 | } |
| 9 | |
| 10 | property<int> count: 5; |
| 11 | |
| 12 | for foo[idx] in count: Rectangle { |
| 13 | x: idx * 1phx; |
| 14 | ccc := Text { |
| 15 | x: idx * 1phx; |
| 16 | text: aaa.text; |
| 17 | y: foo * 1phx; |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | for gre[mem] in err: Rectangle { |
| 22 | //^error{Unknown unqualified identifier 'err'} |
| 23 | x: mem * 1phx; |
| 24 | ddd := Text { text: ccc.text; } |
| 25 | // ^error{Cannot access id 'ccc'} |
| 26 | } |
| 27 | |
| 28 | for plop in 0 : named_for := Rectangle { |
| 29 | Text { color: named_for.background; } |
| 30 | } |
| 31 | |
| 32 | Text { |
| 33 | text: ccc.text; |
| 34 | // ^error{Cannot access id 'ccc'} |
| 35 | color: named_for.background; |
| 36 | // ^error{Cannot access id 'named_for'} |
| 37 | } |
| 38 | |
| 39 | for aaa in aaa.text: Rectangle { |
| 40 | // ^error{Cannot convert string to model} |
| 41 | } |
| 42 | |
| 43 | for plop in [1,2,3,4]: Rectangle { |
| 44 | x: plop * 1phx; |
| 45 | Rectangle { |
| 46 | background: plop; |
| 47 | // ^error{Cannot convert float to brush} |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | for pp[idx] in [1,3,2]: Rectangle { |
| 52 | x: idx * 1phx; |
| 53 | y: 25phx * pp; |
| 54 | } |
| 55 | |
| 56 | for pp[idx] in [{a: 1phx, b: "P" },{a: 2phx, b: "Q" }]: Text { |
| 57 | x: pp.a; |
| 58 | text: pp.b; |
| 59 | y: pp.b; |
| 60 | // ^error{Cannot convert string to length} |
| 61 | property<int> ggg: pp; |
| 62 | // ^error{Cannot convert \{ a: physical-length,b: string,\} to int} |
| 63 | } |
| 64 | |
| 65 | |
| 66 | for pp[idx] in [{a: 1, b: "P" },{a: 2, c: 1}]: Text { |
| 67 | text: pp.b; // Ok! pp will have a, b and c properties, and b will be the empty string. |
| 68 | } |
| 69 | |
| 70 | // issue 4683 |
| 71 | if issue_4683.shown : issue_4683 := TouchArea { |
| 72 | // ^error{Cannot access id 'issue_4683'} |
| 73 | property <bool> shown: true; |
| 74 | clicked => { shown = !shown; } |
| 75 | } |
| 76 | |
| 77 | for xx in inner_for.model: inner_for := Rectangle { |
| 78 | // ^error{Cannot access id 'inner_for'} |
| 79 | property <[int]> model: [1,2,3,4]; |
| 80 | } |
| 81 | |
| 82 | for xx in inner_model: Rectangle { |
| 83 | // ^error{Unknown unqualified identifier 'inner_model'} |
| 84 | property <[int]> inner_model: [1,2,3,4]; |
| 85 | } |
| 86 | |
| 87 | if element_inside_if.pressed : Rectangle { |
| 88 | // ^error{Cannot access id 'element_inside_if'} |
| 89 | element_inside_if := TouchArea {} |
| 90 | } |
| 91 | |
| 92 | if self.pressed : TouchArea { } |
| 93 | // ^error{Element 'Rectangle' does not have a property 'pressed'} |
| 94 | |
| 95 | |
| 96 | for i[idx] in [] : Text { text: idx; } |
| 97 | // ^error{Cannot convert \[void] to model} |
| 98 | } |
| 99 | |