Skip to content

Commit ae73f37

Browse files
committed
add test cases for lambda
1 parent 1782285 commit ae73f37

File tree

193 files changed

+30909
-12
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+30909
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,336 @@
1+
// -- Model dump before env processor pipeline:
2+
module 0xcafe::m {
3+
private fun map(x: u64,f: |u64|u64): u64 {
4+
(f)(x)
5+
}
6+
private fun no_name_clash(x: u64,c: u64): u64 {
7+
m::map(x, |y: u64| Add<u64>(y, c))
8+
}
9+
private fun with_name_clash1(x: u64,c: u64): u64 {
10+
m::map(x, |x: u64| Add<u64>(x, c))
11+
}
12+
private fun with_name_clash2(x: u64,c: u64): u64 {
13+
m::map(x, |x: u64| Add<u64>({
14+
let x: u64 = Add<u64>(c, 1);
15+
x
16+
}, x))
17+
}
18+
} // end 0xcafe::m
19+
20+
21+
// -- Model dump after env processor unused checks:
22+
module 0xcafe::m {
23+
private fun map(x: u64,f: |u64|u64): u64 {
24+
(f)(x)
25+
}
26+
private fun no_name_clash(x: u64,c: u64): u64 {
27+
m::map(x, |y: u64| Add<u64>(y, c))
28+
}
29+
private fun with_name_clash1(x: u64,c: u64): u64 {
30+
m::map(x, |x: u64| Add<u64>(x, c))
31+
}
32+
private fun with_name_clash2(x: u64,c: u64): u64 {
33+
m::map(x, |x: u64| Add<u64>({
34+
let x: u64 = Add<u64>(c, 1);
35+
x
36+
}, x))
37+
}
38+
} // end 0xcafe::m
39+
40+
41+
// -- Model dump after env processor type parameter check:
42+
module 0xcafe::m {
43+
private fun map(x: u64,f: |u64|u64): u64 {
44+
(f)(x)
45+
}
46+
private fun no_name_clash(x: u64,c: u64): u64 {
47+
m::map(x, |y: u64| Add<u64>(y, c))
48+
}
49+
private fun with_name_clash1(x: u64,c: u64): u64 {
50+
m::map(x, |x: u64| Add<u64>(x, c))
51+
}
52+
private fun with_name_clash2(x: u64,c: u64): u64 {
53+
m::map(x, |x: u64| Add<u64>({
54+
let x: u64 = Add<u64>(c, 1);
55+
x
56+
}, x))
57+
}
58+
} // end 0xcafe::m
59+
60+
61+
// -- Model dump after env processor check recursive struct definition:
62+
module 0xcafe::m {
63+
private fun map(x: u64,f: |u64|u64): u64 {
64+
(f)(x)
65+
}
66+
private fun no_name_clash(x: u64,c: u64): u64 {
67+
m::map(x, |y: u64| Add<u64>(y, c))
68+
}
69+
private fun with_name_clash1(x: u64,c: u64): u64 {
70+
m::map(x, |x: u64| Add<u64>(x, c))
71+
}
72+
private fun with_name_clash2(x: u64,c: u64): u64 {
73+
m::map(x, |x: u64| Add<u64>({
74+
let x: u64 = Add<u64>(c, 1);
75+
x
76+
}, x))
77+
}
78+
} // end 0xcafe::m
79+
80+
81+
// -- Model dump after env processor check cyclic type instantiation:
82+
module 0xcafe::m {
83+
private fun map(x: u64,f: |u64|u64): u64 {
84+
(f)(x)
85+
}
86+
private fun no_name_clash(x: u64,c: u64): u64 {
87+
m::map(x, |y: u64| Add<u64>(y, c))
88+
}
89+
private fun with_name_clash1(x: u64,c: u64): u64 {
90+
m::map(x, |x: u64| Add<u64>(x, c))
91+
}
92+
private fun with_name_clash2(x: u64,c: u64): u64 {
93+
m::map(x, |x: u64| Add<u64>({
94+
let x: u64 = Add<u64>(c, 1);
95+
x
96+
}, x))
97+
}
98+
} // end 0xcafe::m
99+
100+
101+
// -- Model dump after env processor unused struct params check:
102+
module 0xcafe::m {
103+
private fun map(x: u64,f: |u64|u64): u64 {
104+
(f)(x)
105+
}
106+
private fun no_name_clash(x: u64,c: u64): u64 {
107+
m::map(x, |y: u64| Add<u64>(y, c))
108+
}
109+
private fun with_name_clash1(x: u64,c: u64): u64 {
110+
m::map(x, |x: u64| Add<u64>(x, c))
111+
}
112+
private fun with_name_clash2(x: u64,c: u64): u64 {
113+
m::map(x, |x: u64| Add<u64>({
114+
let x: u64 = Add<u64>(c, 1);
115+
x
116+
}, x))
117+
}
118+
} // end 0xcafe::m
119+
120+
121+
// -- Model dump after env processor access and use check before inlining:
122+
module 0xcafe::m {
123+
private fun map(x: u64,f: |u64|u64): u64 {
124+
(f)(x)
125+
}
126+
private fun no_name_clash(x: u64,c: u64): u64 {
127+
m::map(x, |y: u64| Add<u64>(y, c))
128+
}
129+
private fun with_name_clash1(x: u64,c: u64): u64 {
130+
m::map(x, |x: u64| Add<u64>(x, c))
131+
}
132+
private fun with_name_clash2(x: u64,c: u64): u64 {
133+
m::map(x, |x: u64| Add<u64>({
134+
let x: u64 = Add<u64>(c, 1);
135+
x
136+
}, x))
137+
}
138+
} // end 0xcafe::m
139+
140+
141+
// -- Model dump after env processor inlining:
142+
module 0xcafe::m {
143+
private fun map(x: u64,f: |u64|u64): u64 {
144+
(f)(x)
145+
}
146+
private fun no_name_clash(x: u64,c: u64): u64 {
147+
m::map(x, |y: u64| Add<u64>(y, c))
148+
}
149+
private fun with_name_clash1(x: u64,c: u64): u64 {
150+
m::map(x, |x: u64| Add<u64>(x, c))
151+
}
152+
private fun with_name_clash2(x: u64,c: u64): u64 {
153+
m::map(x, |x: u64| Add<u64>({
154+
let x: u64 = Add<u64>(c, 1);
155+
x
156+
}, x))
157+
}
158+
} // end 0xcafe::m
159+
160+
161+
// -- Model dump after env processor access and use check after inlining:
162+
module 0xcafe::m {
163+
private fun map(x: u64,f: |u64|u64): u64 {
164+
(f)(x)
165+
}
166+
private fun no_name_clash(x: u64,c: u64): u64 {
167+
m::map(x, |y: u64| Add<u64>(y, c))
168+
}
169+
private fun with_name_clash1(x: u64,c: u64): u64 {
170+
m::map(x, |x: u64| Add<u64>(x, c))
171+
}
172+
private fun with_name_clash2(x: u64,c: u64): u64 {
173+
m::map(x, |x: u64| Add<u64>({
174+
let x: u64 = Add<u64>(c, 1);
175+
x
176+
}, x))
177+
}
178+
} // end 0xcafe::m
179+
180+
181+
// -- Model dump after env processor acquires check:
182+
module 0xcafe::m {
183+
private fun map(x: u64,f: |u64|u64): u64 {
184+
(f)(x)
185+
}
186+
private fun no_name_clash(x: u64,c: u64): u64 {
187+
m::map(x, |y: u64| Add<u64>(y, c))
188+
}
189+
private fun with_name_clash1(x: u64,c: u64): u64 {
190+
m::map(x, |x: u64| Add<u64>(x, c))
191+
}
192+
private fun with_name_clash2(x: u64,c: u64): u64 {
193+
m::map(x, |x: u64| Add<u64>({
194+
let x: u64 = Add<u64>(c, 1);
195+
x
196+
}, x))
197+
}
198+
} // end 0xcafe::m
199+
200+
201+
// -- Model dump after env processor simplifier:
202+
module 0xcafe::m {
203+
private fun map(x: u64,f: |u64|u64): u64 {
204+
(f)(x)
205+
}
206+
private fun no_name_clash(x: u64,c: u64): u64 {
207+
m::map(x, |y: u64| Add<u64>(y, c))
208+
}
209+
private fun with_name_clash1(x: u64,c: u64): u64 {
210+
m::map(x, |x: u64| Add<u64>(x, c))
211+
}
212+
private fun with_name_clash2(x: u64,c: u64): u64 {
213+
m::map(x, |x: u64| Add<u64>({
214+
let x: u64 = Add<u64>(c, 1);
215+
x
216+
}, x))
217+
}
218+
} // end 0xcafe::m
219+
220+
221+
// -- Model dump after env processor lambda-lifting:
222+
module 0xcafe::m {
223+
private fun map(x: u64,f: |u64|u64): u64 {
224+
(f)(x)
225+
}
226+
private fun no_name_clash(x: u64,c: u64): u64 {
227+
m::map(x, closure m::no_name_clash$lambda$1(c))
228+
}
229+
private fun with_name_clash1(x: u64,c: u64): u64 {
230+
m::map(x, closure m::with_name_clash1$lambda$1(c))
231+
}
232+
private fun with_name_clash2(x: u64,c: u64): u64 {
233+
m::map(x, closure m::with_name_clash2$lambda$1(c))
234+
}
235+
private fun no_name_clash$lambda$1(c: u64,y: u64): u64 {
236+
Add<u64>(y, c)
237+
}
238+
private fun with_name_clash1$lambda$1(c: u64,x: u64): u64 {
239+
Add<u64>(x, c)
240+
}
241+
private fun with_name_clash2$lambda$1(c: u64,x: u64): u64 {
242+
Add<u64>({
243+
let x: u64 = Add<u64>(c, 1);
244+
x
245+
}, x)
246+
}
247+
} // end 0xcafe::m
248+
249+
250+
// -- Model dump after env processor specification checker:
251+
module 0xcafe::m {
252+
private fun map(x: u64,f: |u64|u64): u64 {
253+
(f)(x)
254+
}
255+
private fun no_name_clash(x: u64,c: u64): u64 {
256+
m::map(x, closure m::no_name_clash$lambda$1(c))
257+
}
258+
private fun with_name_clash1(x: u64,c: u64): u64 {
259+
m::map(x, closure m::with_name_clash1$lambda$1(c))
260+
}
261+
private fun with_name_clash2(x: u64,c: u64): u64 {
262+
m::map(x, closure m::with_name_clash2$lambda$1(c))
263+
}
264+
private fun no_name_clash$lambda$1(c: u64,y: u64): u64 {
265+
Add<u64>(y, c)
266+
}
267+
private fun with_name_clash1$lambda$1(c: u64,x: u64): u64 {
268+
Add<u64>(x, c)
269+
}
270+
private fun with_name_clash2$lambda$1(c: u64,x: u64): u64 {
271+
Add<u64>({
272+
let x: u64 = Add<u64>(c, 1);
273+
x
274+
}, x)
275+
}
276+
} // end 0xcafe::m
277+
278+
279+
// -- Model dump after env processor specification rewriter:
280+
module 0xcafe::m {
281+
private fun map(x: u64,f: |u64|u64): u64 {
282+
(f)(x)
283+
}
284+
private fun no_name_clash(x: u64,c: u64): u64 {
285+
m::map(x, closure m::no_name_clash$lambda$1(c))
286+
}
287+
private fun with_name_clash1(x: u64,c: u64): u64 {
288+
m::map(x, closure m::with_name_clash1$lambda$1(c))
289+
}
290+
private fun with_name_clash2(x: u64,c: u64): u64 {
291+
m::map(x, closure m::with_name_clash2$lambda$1(c))
292+
}
293+
private fun no_name_clash$lambda$1(c: u64,y: u64): u64 {
294+
Add<u64>(y, c)
295+
}
296+
private fun with_name_clash1$lambda$1(c: u64,x: u64): u64 {
297+
Add<u64>(x, c)
298+
}
299+
private fun with_name_clash2$lambda$1(c: u64,x: u64): u64 {
300+
Add<u64>({
301+
let x: u64 = Add<u64>(c, 1);
302+
x
303+
}, x)
304+
}
305+
} // end 0xcafe::m
306+
307+
308+
309+
Diagnostics:
310+
error: Calls to function values other than inline function parameters not yet supported
311+
┌─ tests/lambda-lifting/basic.move:5:9
312+
313+
5 │ f(x)
314+
│ ^
315+
316+
error: Function-typed values not yet supported except as parameters to calls to inline functions
317+
┌─ tests/lambda-lifting/basic.move:10:16
318+
319+
10 │ map(x, |y| y + c)
320+
│ ^^^^^^^^^
321+
322+
error: Function-typed values not yet supported except as parameters to calls to inline functions
323+
┌─ tests/lambda-lifting/basic.move:15:16
324+
325+
15 │ map(x, |x| x + c)
326+
│ ^^^^^^^^^
327+
328+
error: Function-typed values not yet supported except as parameters to calls to inline functions
329+
┌─ tests/lambda-lifting/basic.move:20:16
330+
331+
20 │ map(x, |x| {
332+
│ ╭────────────────^
333+
21 │ │ let x = c + 1;
334+
22 │ │ x
335+
23 │ │ } + x)
336+
│ ╰─────────────^

0 commit comments

Comments
 (0)