Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[compiler-v2] add test cases for lambda #14791

Merged
merged 4 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,336 @@
// -- Model dump before env processor pipeline:
module 0xcafe::m {
private fun map(x: u64,f: |u64|u64): u64 {
(f)(x)
}
private fun no_name_clash(x: u64,c: u64): u64 {
m::map(x, |y: u64| Add<u64>(y, c))
}
private fun with_name_clash1(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>(x, c))
}
private fun with_name_clash2(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>({
let x: u64 = Add<u64>(c, 1);
x
}, x))
}
} // end 0xcafe::m


// -- Model dump after env processor unused checks:
module 0xcafe::m {
private fun map(x: u64,f: |u64|u64): u64 {
(f)(x)
}
private fun no_name_clash(x: u64,c: u64): u64 {
m::map(x, |y: u64| Add<u64>(y, c))
}
private fun with_name_clash1(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>(x, c))
}
private fun with_name_clash2(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>({
let x: u64 = Add<u64>(c, 1);
x
}, x))
}
} // end 0xcafe::m


// -- Model dump after env processor type parameter check:
module 0xcafe::m {
private fun map(x: u64,f: |u64|u64): u64 {
(f)(x)
}
private fun no_name_clash(x: u64,c: u64): u64 {
m::map(x, |y: u64| Add<u64>(y, c))
}
private fun with_name_clash1(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>(x, c))
}
private fun with_name_clash2(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>({
let x: u64 = Add<u64>(c, 1);
x
}, x))
}
} // end 0xcafe::m


// -- Model dump after env processor check recursive struct definition:
module 0xcafe::m {
private fun map(x: u64,f: |u64|u64): u64 {
(f)(x)
}
private fun no_name_clash(x: u64,c: u64): u64 {
m::map(x, |y: u64| Add<u64>(y, c))
}
private fun with_name_clash1(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>(x, c))
}
private fun with_name_clash2(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>({
let x: u64 = Add<u64>(c, 1);
x
}, x))
}
} // end 0xcafe::m


// -- Model dump after env processor check cyclic type instantiation:
module 0xcafe::m {
private fun map(x: u64,f: |u64|u64): u64 {
(f)(x)
}
private fun no_name_clash(x: u64,c: u64): u64 {
m::map(x, |y: u64| Add<u64>(y, c))
}
private fun with_name_clash1(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>(x, c))
}
private fun with_name_clash2(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>({
let x: u64 = Add<u64>(c, 1);
x
}, x))
}
} // end 0xcafe::m


// -- Model dump after env processor unused struct params check:
module 0xcafe::m {
private fun map(x: u64,f: |u64|u64): u64 {
(f)(x)
}
private fun no_name_clash(x: u64,c: u64): u64 {
m::map(x, |y: u64| Add<u64>(y, c))
}
private fun with_name_clash1(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>(x, c))
}
private fun with_name_clash2(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>({
let x: u64 = Add<u64>(c, 1);
x
}, x))
}
} // end 0xcafe::m


// -- Model dump after env processor access and use check before inlining:
module 0xcafe::m {
private fun map(x: u64,f: |u64|u64): u64 {
(f)(x)
}
private fun no_name_clash(x: u64,c: u64): u64 {
m::map(x, |y: u64| Add<u64>(y, c))
}
private fun with_name_clash1(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>(x, c))
}
private fun with_name_clash2(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>({
let x: u64 = Add<u64>(c, 1);
x
}, x))
}
} // end 0xcafe::m


// -- Model dump after env processor inlining:
module 0xcafe::m {
private fun map(x: u64,f: |u64|u64): u64 {
(f)(x)
}
private fun no_name_clash(x: u64,c: u64): u64 {
m::map(x, |y: u64| Add<u64>(y, c))
}
private fun with_name_clash1(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>(x, c))
}
private fun with_name_clash2(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>({
let x: u64 = Add<u64>(c, 1);
x
}, x))
}
} // end 0xcafe::m


// -- Model dump after env processor access and use check after inlining:
module 0xcafe::m {
private fun map(x: u64,f: |u64|u64): u64 {
(f)(x)
}
private fun no_name_clash(x: u64,c: u64): u64 {
m::map(x, |y: u64| Add<u64>(y, c))
}
private fun with_name_clash1(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>(x, c))
}
private fun with_name_clash2(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>({
let x: u64 = Add<u64>(c, 1);
x
}, x))
}
} // end 0xcafe::m


// -- Model dump after env processor acquires check:
module 0xcafe::m {
private fun map(x: u64,f: |u64|u64): u64 {
(f)(x)
}
private fun no_name_clash(x: u64,c: u64): u64 {
m::map(x, |y: u64| Add<u64>(y, c))
}
private fun with_name_clash1(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>(x, c))
}
private fun with_name_clash2(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>({
let x: u64 = Add<u64>(c, 1);
x
}, x))
}
} // end 0xcafe::m


// -- Model dump after env processor simplifier:
module 0xcafe::m {
private fun map(x: u64,f: |u64|u64): u64 {
(f)(x)
}
private fun no_name_clash(x: u64,c: u64): u64 {
m::map(x, |y: u64| Add<u64>(y, c))
}
private fun with_name_clash1(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>(x, c))
}
private fun with_name_clash2(x: u64,c: u64): u64 {
m::map(x, |x: u64| Add<u64>({
let x: u64 = Add<u64>(c, 1);
x
}, x))
}
} // end 0xcafe::m


// -- Model dump after env processor lambda-lifting:
module 0xcafe::m {
private fun map(x: u64,f: |u64|u64): u64 {
(f)(x)
}
private fun no_name_clash(x: u64,c: u64): u64 {
m::map(x, closure m::no_name_clash$lambda$1(c))
}
private fun with_name_clash1(x: u64,c: u64): u64 {
m::map(x, closure m::with_name_clash1$lambda$1(c))
}
private fun with_name_clash2(x: u64,c: u64): u64 {
m::map(x, closure m::with_name_clash2$lambda$1(c))
}
private fun no_name_clash$lambda$1(c: u64,y: u64): u64 {
Add<u64>(y, c)
}
private fun with_name_clash1$lambda$1(c: u64,x: u64): u64 {
Add<u64>(x, c)
}
private fun with_name_clash2$lambda$1(c: u64,x: u64): u64 {
Add<u64>({
let x: u64 = Add<u64>(c, 1);
x
}, x)
}
} // end 0xcafe::m


// -- Model dump after env processor specification checker:
module 0xcafe::m {
private fun map(x: u64,f: |u64|u64): u64 {
(f)(x)
}
private fun no_name_clash(x: u64,c: u64): u64 {
m::map(x, closure m::no_name_clash$lambda$1(c))
}
private fun with_name_clash1(x: u64,c: u64): u64 {
m::map(x, closure m::with_name_clash1$lambda$1(c))
}
private fun with_name_clash2(x: u64,c: u64): u64 {
m::map(x, closure m::with_name_clash2$lambda$1(c))
}
private fun no_name_clash$lambda$1(c: u64,y: u64): u64 {
Add<u64>(y, c)
}
private fun with_name_clash1$lambda$1(c: u64,x: u64): u64 {
Add<u64>(x, c)
}
private fun with_name_clash2$lambda$1(c: u64,x: u64): u64 {
Add<u64>({
let x: u64 = Add<u64>(c, 1);
x
}, x)
}
} // end 0xcafe::m


// -- Model dump after env processor specification rewriter:
module 0xcafe::m {
private fun map(x: u64,f: |u64|u64): u64 {
(f)(x)
}
private fun no_name_clash(x: u64,c: u64): u64 {
m::map(x, closure m::no_name_clash$lambda$1(c))
}
private fun with_name_clash1(x: u64,c: u64): u64 {
m::map(x, closure m::with_name_clash1$lambda$1(c))
}
private fun with_name_clash2(x: u64,c: u64): u64 {
m::map(x, closure m::with_name_clash2$lambda$1(c))
}
private fun no_name_clash$lambda$1(c: u64,y: u64): u64 {
Add<u64>(y, c)
}
private fun with_name_clash1$lambda$1(c: u64,x: u64): u64 {
Add<u64>(x, c)
}
private fun with_name_clash2$lambda$1(c: u64,x: u64): u64 {
Add<u64>({
let x: u64 = Add<u64>(c, 1);
x
}, x)
}
} // end 0xcafe::m



Diagnostics:
error: Calls to function values other than inline function parameters not yet supported
┌─ tests/lambda-lifting/basic.move:5:9
5 │ f(x)
│ ^

error: Function-typed values not yet supported except as parameters to calls to inline functions
┌─ tests/lambda-lifting/basic.move:10:16
10 │ map(x, |y| y + c)
│ ^^^^^^^^^

error: Function-typed values not yet supported except as parameters to calls to inline functions
┌─ tests/lambda-lifting/basic.move:15:16
15 │ map(x, |x| x + c)
│ ^^^^^^^^^

error: Function-typed values not yet supported except as parameters to calls to inline functions
┌─ tests/lambda-lifting/basic.move:20:16
20 │ map(x, |x| {
│ ╭────────────────^
21 │ │ let x = c + 1;
22 │ │ x
23 │ │ } + x)
│ ╰─────────────^
Loading
Loading