-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[move-compiler-v2] clean up a few remaining issues in lambda parser/f…
…ront-end code (#15365) - Distinguish between "not supported" and "not implemented" for lambda features. - Add a test case to illustrate the function name aliasing issue ([Bug][move-compiler-v2] visible function names shadow local variables with same name in function calls #15360), but changed other tests here to avoid it. - Remove Constraint::NoFunction as it's too broad. - Make sure there are still errors for all planned unsupported cases - Fix LambdaLifter case for bound free variable without copy. - Refine lambda test cases to make _ok versions that compile up to "not implemented" errors.
- Loading branch information
1 parent
966452a
commit c6f5752
Showing
38 changed files
with
10,999 additions
and
484 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
third_party/move/move-compiler-v2/tests/checking/inlining/function_name_shadowing.exp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
|
||
Diagnostics: | ||
warning: Unused parameter `f`. Consider removing or prefixing with an underscore: `_f` | ||
┌─ tests/checking/inlining/function_name_shadowing.move:20:28 | ||
│ | ||
20 │ public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 { | ||
│ ^ | ||
|
||
warning: Unused parameter `g`. Consider removing or prefixing with an underscore: `_g` | ||
┌─ tests/checking/inlining/function_name_shadowing.move:20:45 | ||
│ | ||
20 │ public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 { | ||
│ ^ | ||
|
||
warning: Unused parameter `i`. Consider removing or prefixing with an underscore: `_i` | ||
┌─ tests/checking/inlining/function_name_shadowing.move:20:57 | ||
│ | ||
20 │ public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 { | ||
│ ^ | ||
|
||
// -- Model dump before bytecode pipeline | ||
module 0x42::OtherModule { | ||
public fun g(a: u64,b: u64): u64 { | ||
Add<u64>(a, b) | ||
} | ||
public fun h(a: u64,b: u64): u64 { | ||
Add<u64>(Mul<u64>(2, a), b) | ||
} | ||
} // end 0x42::OtherModule | ||
module 0x42::Test { | ||
use 0x42::OtherModule::{g}; // resolved as: 0x42::OtherModule | ||
public fun f(a: u64,b: u64): u64 { | ||
Mul<u64>(a, b) | ||
} | ||
public inline fun quux(f: |(u64, u64)|u64,g: |u64|u64,i: |u8|u8,a: u64,b: u64): u64 { | ||
Mul<u64>(Mul<u64>(Test::f(a, b), OtherModule::g(a, b)), OtherModule::h(a, b)) | ||
} | ||
public fun test_shadowing(): u64 { | ||
Mul<u64>(Mul<u64>(Test::f(10, 2), OtherModule::g(10, 2)), OtherModule::h(10, 2)) | ||
} | ||
} // end 0x42::Test | ||
|
||
// -- Sourcified model before bytecode pipeline | ||
module 0x42::OtherModule { | ||
public fun g(a: u64, b: u64): u64 { | ||
a + b | ||
} | ||
public fun h(a: u64, b: u64): u64 { | ||
2 * a + b | ||
} | ||
} | ||
module 0x42::Test { | ||
use 0x42::OtherModule; | ||
public fun f(a: u64, b: u64): u64 { | ||
a * b | ||
} | ||
public inline fun quux(f: |(u64, u64)|u64, g: |u64|u64, i: |u8|u8, a: u64, b: u64): u64 { | ||
f(a, b) * OtherModule::g(a, b) * OtherModule::h(a, b) | ||
} | ||
public fun test_shadowing(): u64 { | ||
f(10, 2) * OtherModule::g(10, 2) * OtherModule::h(10, 2) | ||
} | ||
} | ||
|
||
|
||
============ bytecode verification succeeded ======== |
30 changes: 30 additions & 0 deletions
30
third_party/move/move-compiler-v2/tests/checking/inlining/function_name_shadowing.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//# publish | ||
module 0x42::OtherModule { | ||
public fun g(a: u64, b: u64): u64 { | ||
a + b | ||
} | ||
|
||
public fun h(a: u64, b: u64): u64 { | ||
2 * a + b | ||
} | ||
} | ||
|
||
//# publish | ||
module 0x42::Test { | ||
use 0x42::OtherModule::g; | ||
|
||
public fun f(a: u64, b: u64): u64 { | ||
a * b | ||
} | ||
|
||
public inline fun quux(f:|u64, u64|u64, g:|u64|u64, i:|u8|u8, a: u64, b: u64): u64 { | ||
use 0x42::OtherModule::h; | ||
f(a, b) * g(a, b) * h(a, b) | ||
} | ||
|
||
public fun test_shadowing(): u64 { | ||
quux(|a, b| a - b, |a| a + 2, |b| 255u8-b, 10, 2) | ||
} | ||
} | ||
|
||
//# run 0x42::Test::test_shadowing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.