-
Notifications
You must be signed in to change notification settings - Fork 740
Expand file tree
/
Copy pathstructure
More file actions
169 lines (132 loc) · 2.87 KB
/
structure
File metadata and controls
169 lines (132 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
//! > Constructor
//! > test_runner_name
test_function_diagnostics(expect_diagnostics: true)
//! > function_code
#[cairofmt::skip]
fn foo(a: A) -> A {
A {
b: 1_felt252,
a: 2,
c: 7,
a: 3,
..d,
f: 4,
}
}
//! > function_name
foo
//! > module_code
struct A {
a: felt252,
b: (),
}
//! > expected_diagnostics
error[E2041]: Unexpected argument type. Expected: "()", found: "core::felt252".
--> lib.cairo:8:12
b: 1_felt252,
^^^^^^^^^
error[E2018]: Unknown member.
--> lib.cairo:10:9
c: 7,
^
error[E2021]: Member specified more than once.
--> lib.cairo:11:9
a: 3,
^
error[E2022]: The base struct must always be the last argument.
--> lib.cairo:12:9
..d,
^^^
error[E2018]: Unknown member.
--> lib.cairo:13:9
f: 4,
^
//! > ==========================================================================
//! > Blocks, `if`s, and `match`s, don't require semicolon, even not in tail expressions.
//! > test_runner_name
test_function_diagnostics(expect_diagnostics: true)
//! > function_code
fn foo(a: A) {
a.f;
a.a::b;
a.4.4;
5_felt252.a;
}
//! > function_name
foo
//! > module_code
struct A {
a: (felt252,),
b: felt252,
c: felt252,
}
//! > expected_diagnostics
error[E0007]: Type "test::A" has no member "f"
--> lib.cairo:7:7
a.f;
^
error[E2085]: Invalid member expression.
--> lib.cairo:8:7
a.a::b;
^^^^
error[E2085]: Invalid member expression.
--> lib.cairo:9:7
a.4.4;
^
error[E2085]: Invalid member expression.
--> lib.cairo:9:9
a.4.4;
^
error[E0007]: Type "core::felt252" has no member "a"
--> lib.cairo:10:15
5_felt252.a;
^
//! > ==========================================================================
//! > No effect tail struct.
//! > test_runner_name
test_function_diagnostics(expect_diagnostics: true)
//! > function_code
fn foo(a: A) -> A {
A { a: 4, ..a }
}
//! > function_name
foo
//! > module_code
struct A {
a: felt252,
}
//! > expected_diagnostics
error[E2023]: Base struct has no effect, all the fields in the struct have already been specified.
--> lib.cairo:5:15
A { a: 4, ..a }
^^^
//! > ==========================================================================
//! > Member access on unreduced impl associated type.
//! > test_runner_name
test_function_diagnostics(expect_diagnostics: true)
//! > function_code
fn foo() {}
//! > function_name
foo
//! > module_code
struct S {
val: felt252,
}
trait T<X> {
type A;
fn f(self: @X) -> Self::A;
}
impl I of T<S> {
type A = S;
fn f(self: @S) -> S {
S { val: 0 }
}
}
fn g<X, impl H: T<X>>(x: @X) -> felt252 {
H::f(x).val
}
//! > expected_diagnostics
error[E2057]: Type "H::A" has no members.
--> lib.cairo:18:13
H::f(x).val
^^^