From f0eef27536fadf9322303d6dd8fcd1d0dab4341a Mon Sep 17 00:00:00 2001 From: Vineeth Kashyap Date: Fri, 5 Apr 2024 20:28:13 -0400 Subject: [PATCH 1/8] Showcase the problem --- .../moved_var_not_simplified3.exp | 0 .../moved_var_not_simplified3.move | 0 .../tests/bytecode-generator/wildcard1.exp | 7 +++ .../tests/bytecode-generator/wildcard1.move | 9 ++++ .../tests/bytecode-generator/wildcard2.exp | 23 ++++++++ .../tests/bytecode-generator/wildcard2.move | 6 +++ .../tests/bytecode-generator/wildcard3.exp | 52 +++++++++++++++++++ .../tests/bytecode-generator/wildcard3.move | 12 +++++ .../tests/bytecode-generator/wildcard4.exp | 49 +++++++++++++++++ .../tests/bytecode-generator/wildcard4.move | 9 ++++ .../move/move-compiler-v2/tests/testsuite.rs | 6 +-- 11 files changed, 170 insertions(+), 3 deletions(-) rename third_party/move/move-compiler-v2/tests/{no-simplifier => bytecode-generator}/moved_var_not_simplified3.exp (100%) rename third_party/move/move-compiler-v2/tests/{no-simplifier => bytecode-generator}/moved_var_not_simplified3.move (100%) create mode 100644 third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard1.exp create mode 100644 third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard1.move create mode 100644 third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard2.exp create mode 100644 third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard2.move create mode 100644 third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard3.exp create mode 100644 third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard3.move create mode 100644 third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard4.exp create mode 100644 third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard4.move diff --git a/third_party/move/move-compiler-v2/tests/no-simplifier/moved_var_not_simplified3.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/moved_var_not_simplified3.exp similarity index 100% rename from third_party/move/move-compiler-v2/tests/no-simplifier/moved_var_not_simplified3.exp rename to third_party/move/move-compiler-v2/tests/bytecode-generator/moved_var_not_simplified3.exp diff --git a/third_party/move/move-compiler-v2/tests/no-simplifier/moved_var_not_simplified3.move b/third_party/move/move-compiler-v2/tests/bytecode-generator/moved_var_not_simplified3.move similarity index 100% rename from third_party/move/move-compiler-v2/tests/no-simplifier/moved_var_not_simplified3.move rename to third_party/move/move-compiler-v2/tests/bytecode-generator/moved_var_not_simplified3.move diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard1.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard1.exp new file mode 100644 index 0000000000000..50c25a1cc25c9 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard1.exp @@ -0,0 +1,7 @@ + +Diagnostics: +error: the left-hand side has 2 items but the right-hand side provided 1 + ┌─ tests/bytecode-generator/wildcard1.move:7:13 + │ +7 │ let _ = tup(); + │ ^ diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard1.move b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard1.move new file mode 100644 index 0000000000000..4434885e2308b --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard1.move @@ -0,0 +1,9 @@ +module 0xc0ffee::m { + fun tup(): (u64, u64) { + (0, 0) + } + + public fun bar() { + let _ = tup(); + } +} diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard2.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard2.exp new file mode 100644 index 0000000000000..658944ca7dfdf --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard2.exp @@ -0,0 +1,23 @@ +// -- Model dump before bytecode pipeline +module 0xc0ffee::m { + public fun baz() { + { + let x: u64; + { + let _: u64 = x; + Tuple() + } + } + } +} // end 0xc0ffee::m + +============ initial bytecode ================ + +[variant baseline] +public fun m::baz() { + var $t0: u64 [unused] + 0: return () +} + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard2.move b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard2.move new file mode 100644 index 0000000000000..9e4e973875ffd --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard2.move @@ -0,0 +1,6 @@ +module 0xc0ffee::m { + public fun baz() { + let x: u64; + let _ = x; + } +} diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard3.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard3.exp new file mode 100644 index 0000000000000..12e852f33c32f --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard3.exp @@ -0,0 +1,52 @@ +// -- Model dump before bytecode pipeline +module 0xc0ffee::m { + struct S { + dummy_field: bool, + } + public fun bar() { + { + let s: m::S = pack m::S(false); + { + let _: m::S = s; + Tuple() + } + } + } + public fun foo(s: m::S) { + { + let _: m::S = s; + Tuple() + } + } +} // end 0xc0ffee::m + +============ initial bytecode ================ + +[variant baseline] +public fun m::bar() { + var $t0: m::S + var $t1: bool + 0: $t1 := false + 1: $t0 := pack m::S($t1) + 2: return () +} + + +[variant baseline] +public fun m::foo($t0: m::S) { + 0: return () +} + + +Diagnostics: +error: local `s` of type `m::S` does not have the `drop` ability + ┌─ tests/bytecode-generator/wildcard3.move:5:18 + │ +5 │ let _ = s; + │ ^ implicitly dropped here since it is no longer used + +error: local `s` of type `m::S` does not have the `drop` ability + ┌─ tests/bytecode-generator/wildcard3.move:9:17 + │ +9 │ let s = S{}; + │ ^^^ implicitly dropped here since it is no longer used diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard3.move b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard3.move new file mode 100644 index 0000000000000..098ed212f9f74 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard3.move @@ -0,0 +1,12 @@ +module 0xc0ffee::m { + struct S {} + + public fun foo(s: S) { + let _ = s; + } + + public fun bar() { + let s = S{}; + let _ = s; + } +} diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard4.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard4.exp new file mode 100644 index 0000000000000..28e3343b78922 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard4.exp @@ -0,0 +1,49 @@ +// -- Model dump before bytecode pipeline +module 0xc0ffee::m { + private fun test() { + { + let x: u64 = 3; + { + let r: &mut u64 = Borrow(Mutable)(x); + { + let y: &mut u64 = Borrow(Mutable)(x); + { + let _: &u64 = Freeze(true)(y); + r = 4; + Tuple() + } + } + } + } + } +} // end 0xc0ffee::m + +============ initial bytecode ================ + +[variant baseline] +fun m::test() { + var $t0: u64 + var $t1: &mut u64 + var $t2: &mut u64 + var $t3: &u64 + var $t4: u64 + 0: $t0 := 3 + 1: $t1 := borrow_local($t0) + 2: $t2 := borrow_local($t0) + 3: $t3 := freeze_ref($t2) + 4: $t4 := 4 + 5: write_ref($t1, $t4) + 6: return () +} + + +Diagnostics: +error: cannot freeze local `y` since multiple mutable references exist + ┌─ tests/bytecode-generator/wildcard4.move:6:17 + │ +4 │ let r = &mut x; + │ ------ conflicting mutable local borrow +5 │ let y = &mut x; + │ ------ originating mutable local borrow +6 │ let _ = freeze(y); + │ ^^^^^^^^^ frozen here diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard4.move b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard4.move new file mode 100644 index 0000000000000..4b84b1e270f93 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard4.move @@ -0,0 +1,9 @@ +module 0xc0ffee::m { + fun test() { + let x = 3; + let r = &mut x; + let y = &mut x; + let _ = freeze(y); + *r = 4; + } +} diff --git a/third_party/move/move-compiler-v2/tests/testsuite.rs b/third_party/move/move-compiler-v2/tests/testsuite.rs index cc386406f6db2..d2c3cecc35867 100644 --- a/third_party/move/move-compiler-v2/tests/testsuite.rs +++ b/third_party/move/move-compiler-v2/tests/testsuite.rs @@ -219,11 +219,11 @@ const TEST_CONFIGS: Lazy> = Lazy::new(|| { exclude: vec![], exp_suffix: None, options: opts.clone(), - // Run the bytecode pipeline as well for double-checking the result - stop_after: StopAfter::BytecodeGen, + // Run the entire compiler pipeline to double-check the result + stop_after: StopAfter::FileFormat, dump_ast: DumpLevel::EndStage, dump_bytecode: DumpLevel::EndStage, - dump_bytecode_filter: None, + dump_bytecode_filter: Some(vec![INITIAL_BYTECODE_STAGE]), }, // -- Tests for stages in the bytecode pipeline // Live-var tests From 50f18b58df01c734366334e197dd784ab28aeedb Mon Sep 17 00:00:00 2001 From: Vineeth Kashyap Date: Fri, 5 Apr 2024 20:30:18 -0400 Subject: [PATCH 2/8] Showcase fix --- .../src/bytecode_generator.rs | 9 +++++-- .../moved_var_not_simplified3.exp | 13 ++++++++++ .../tests/bytecode-generator/wildcard2.exp | 13 +++++++--- .../tests/bytecode-generator/wildcard3.exp | 24 +++++++++++-------- .../tests/bytecode-generator/wildcard4.exp | 10 ++++---- 5 files changed, 50 insertions(+), 19 deletions(-) diff --git a/third_party/move/move-compiler-v2/src/bytecode_generator.rs b/third_party/move/move-compiler-v2/src/bytecode_generator.rs index 9abbb8fd15c1a..2aa7afbd7533d 100644 --- a/third_party/move/move-compiler-v2/src/bytecode_generator.rs +++ b/third_party/move/move-compiler-v2/src/bytecode_generator.rs @@ -1271,8 +1271,13 @@ impl<'env> Generator<'env> { ) { match pat { Pattern::Wildcard(_) => { - // Nothing to do - // TODO(#12475) Should we copy to a temp here? + let ty = self.temp_type(arg).to_owned(); + let temp = self.new_temp(ty); + // Assign to a temporary to allow stackless bytecode checkers to report any errors + // due to the assignment. + self.emit_with(id, |attr| { + Bytecode::Assign(attr, temp, arg, AssignKind::Inferred) + }) }, Pattern::Var(var_id, sym) => { let local = self.find_local_for_pattern(*var_id, *sym, next_scope); diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/moved_var_not_simplified3.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/moved_var_not_simplified3.exp index 2158fe7059dd2..3755b319d9967 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/moved_var_not_simplified3.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/moved_var_not_simplified3.exp @@ -14,5 +14,18 @@ module 0xc0ffee::m { } } // end 0xc0ffee::m +============ initial bytecode ================ + +[variant baseline] +public fun m::test(): u8 { + var $t0: u8 + var $t1: u8 + var $t2: u8 + 0: $t1 := 40 + 1: $t2 := move($t1) + 2: $t0 := infer($t2) + 3: return $t0 +} + ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard2.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard2.exp index 658944ca7dfdf..dd31701d7fac8 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard2.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard2.exp @@ -15,9 +15,16 @@ module 0xc0ffee::m { [variant baseline] public fun m::baz() { - var $t0: u64 [unused] - 0: return () + var $t0: u64 + var $t1: u64 + 0: $t1 := infer($t0) + 1: return () } -============ bytecode verification succeeded ======== +Diagnostics: +error: use of unassigned local `x` + ┌─ tests/bytecode-generator/wildcard2.move:4:13 + │ +4 │ let _ = x; + │ ^ diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard3.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard3.exp index 12e852f33c32f..8b17531c4b9e8 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard3.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard3.exp @@ -26,27 +26,31 @@ module 0xc0ffee::m { public fun m::bar() { var $t0: m::S var $t1: bool + var $t2: m::S 0: $t1 := false 1: $t0 := pack m::S($t1) - 2: return () + 2: $t2 := infer($t0) + 3: return () } [variant baseline] public fun m::foo($t0: m::S) { - 0: return () + var $t1: m::S + 0: $t1 := infer($t0) + 1: return () } Diagnostics: -error: local `s` of type `m::S` does not have the `drop` ability - ┌─ tests/bytecode-generator/wildcard3.move:5:18 +error: value of type `m::S` does not have the `drop` ability + ┌─ tests/bytecode-generator/wildcard3.move:5:13 │ 5 │ let _ = s; - │ ^ implicitly dropped here since it is no longer used + │ ^ implicitly dropped here since it is no longer used -error: local `s` of type `m::S` does not have the `drop` ability - ┌─ tests/bytecode-generator/wildcard3.move:9:17 - │ -9 │ let s = S{}; - │ ^^^ implicitly dropped here since it is no longer used +error: value of type `m::S` does not have the `drop` ability + ┌─ tests/bytecode-generator/wildcard3.move:10:13 + │ +10 │ let _ = s; + │ ^ implicitly dropped here since it is no longer used diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard4.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard4.exp index 28e3343b78922..a09037fa0a35b 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard4.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard4.exp @@ -26,14 +26,16 @@ fun m::test() { var $t1: &mut u64 var $t2: &mut u64 var $t3: &u64 - var $t4: u64 + var $t4: &u64 + var $t5: u64 0: $t0 := 3 1: $t1 := borrow_local($t0) 2: $t2 := borrow_local($t0) 3: $t3 := freeze_ref($t2) - 4: $t4 := 4 - 5: write_ref($t1, $t4) - 6: return () + 4: $t4 := infer($t3) + 5: $t5 := 4 + 6: write_ref($t1, $t5) + 7: return () } From 90a4f0781ef7d3f8f378bb5648b420e53f644a9f Mon Sep 17 00:00:00 2001 From: Vineeth Kashyap Date: Fri, 5 Apr 2024 20:51:21 -0400 Subject: [PATCH 3/8] Update baselines and some tests --- .../tests/bytecode-generator/assign.exp | 3 + .../tests/bytecode-generator/assign.move | 4 +- .../bytecode-generator/assign_inline.exp | 3 + .../tests/bytecode-generator/borrow.exp | 3 + .../bytecode-generator/conditional_borrow.exp | 3 + .../bytecode-generator/escape_autoref.exp | 3 + .../tests/bytecode-generator/fields.exp | 3 + .../tests/bytecode-generator/fields.move | 6 +- .../bytecode-generator/freeze_mut_ref.exp | 13 ++ .../tests/bytecode-generator/globals.exp | 3 + .../tests/bytecode-generator/if_else.exp | 3 + .../tests/bytecode-generator/inline_specs.exp | 3 + .../tests/bytecode-generator/loop.exp | 3 + .../tests/bytecode-generator/operators.exp | 3 + .../tests/bytecode-generator/operators.move | 4 +- .../tests/bytecode-generator/pack_order.exp | 3 + .../tests/bytecode-generator/pack_unpack.exp | 3 + .../reference_conversion.exp | 3 + .../bytecode-generator/spec_construct.exp | 3 + .../tests/bytecode-generator/vector.exp | 3 + .../tests/file-format-generator/vector.exp | 42 +++-- .../v1-locals/use_before_assign_if.exp | 81 +++++---- .../v1-locals/use_before_assign_if_else.exp | 87 +++++---- .../v1-locals/use_before_assign_loop.exp | 122 +++++++------ .../v1-locals/use_before_assign_simple.exp | 79 ++++---- .../v1-locals/use_before_assign_while.exp | 172 +++++++++--------- .../tests/variable-coalescing/inlining1.exp | 10 +- 27 files changed, 403 insertions(+), 265 deletions(-) diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/assign.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/assign.exp index f07b7cfb5f43d..9adcabd110f95 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/assign.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/assign.exp @@ -69,3 +69,6 @@ fun assign::assign_struct($t0: &mut assign::S) { 4: write_ref($t0, $t1) 5: return () } + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/assign.move b/third_party/move/move-compiler-v2/tests/bytecode-generator/assign.move index 2ea2fe8d33721..afa8188675dd0 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/assign.move +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/assign.move @@ -1,11 +1,11 @@ module 0x42::assign { - struct S { + struct S has drop { f: u64, g: T } - struct T { + struct T has drop { h: u64 } diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/assign_inline.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/assign_inline.exp index e141a31f57fd9..73eb01ebbe4ba 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/assign_inline.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/assign_inline.exp @@ -15,3 +15,6 @@ public fun assign::main(): (u64, u64) { 1: $t1 := 3 2: return ($t0, $t1) } + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow.exp index c70b42d96d8f2..1c64fb91482d1 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/borrow.exp @@ -134,3 +134,6 @@ fun borrow::mut_param($t0: u64): u64 { 3: $t1 := read_ref($t2) 4: return $t1 } + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/conditional_borrow.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/conditional_borrow.exp index b4ed5c5a62254..9c7e360aea5b9 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/conditional_borrow.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/conditional_borrow.exp @@ -350,3 +350,6 @@ public fun M::testb(): u64 { 6: $t0 := +($t1, $t4) 7: return $t0 } + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/escape_autoref.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/escape_autoref.exp index ec545ef3da387..3dfca1c2c5e39 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/escape_autoref.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/escape_autoref.exp @@ -87,3 +87,6 @@ fun m::will_autoref(): address { 3: $t0 := read_ref($t3) 4: return $t0 } + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/fields.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/fields.exp index afd1fb0486890..9a0e87baab823 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/fields.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/fields.exp @@ -211,3 +211,6 @@ fun fields::write_val($t0: fields::S): fields::S { 5: $t1 := infer($t0) 6: return $t1 } + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/fields.move b/third_party/move/move-compiler-v2/tests/bytecode-generator/fields.move index 78d9b01619a9d..ea23e39ce5724 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/fields.move +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/fields.move @@ -1,15 +1,15 @@ module 0x42::fields { - struct S { + struct S has drop { f: u64, g: T } - struct T { + struct T has drop { h: u64 } - struct G { + struct G has drop { f: X } diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/freeze_mut_ref.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/freeze_mut_ref.exp index 2750c1b7b343f..ab3905586b4a9 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/freeze_mut_ref.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/freeze_mut_ref.exp @@ -292,3 +292,16 @@ fun freeze_mut_ref::t8($t0: bool, $t1: &mut freeze_mut_ref::S, $t2: &freeze_mut_ 6: label L2 7: return () } + + +Diagnostics: +error: mutable reference in local `s` requires exclusive access but is borrowed + ┌─ tests/bytecode-generator/freeze_mut_ref.move:66:35 + │ +65 │ let f = &mut ({x = x + 1; s}).f; + │ ----------------------- previous mutable field borrow +66 │ let g = &mut ({x = x + 1; s}).f; + │ ^ requirement enforced here + · +69 │ *({*f = 0; z = y; g}) = 2; + │ ------ conflicting reference `f` used here diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/globals.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/globals.exp index ab20dcf2929b6..5015f6fb1c18f 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/globals.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/globals.exp @@ -83,3 +83,6 @@ fun globals::write($t0: address, $t1: u64): u64 { 4: $t2 := 9 5: return $t2 } + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/if_else.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/if_else.exp index fa374099954fa..b8f50f7ed5fbf 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/if_else.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/if_else.exp @@ -72,3 +72,6 @@ fun if_else::if_else_nested($t0: bool, $t1: u64): u64 { 19: label L5 20: return $t2 } + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/inline_specs.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/inline_specs.exp index 9356ac51a0d25..523f94760adc5 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/inline_specs.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/inline_specs.exp @@ -51,3 +51,6 @@ fun inline_specs::succ($t0: u64): u64 { 1: $t1 := +($t0, $t2) 2: return $t1 } + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/loop.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/loop.exp index 4882e1dea81a7..7c1cc30de33ce 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/loop.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/loop.exp @@ -173,3 +173,6 @@ fun loops::while_loop_with_break_and_continue($t0: u64): u64 { 30: $t1 := infer($t0) 31: return $t1 } + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/operators.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/operators.exp index 92f9a57f591c0..0dad714bc08b3 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/operators.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/operators.exp @@ -158,3 +158,6 @@ fun operators::order($t0: u64, $t1: u64): bool { 23: label L8 24: return $t2 } + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/operators.move b/third_party/move/move-compiler-v2/tests/bytecode-generator/operators.move index 84b7e474d18a5..ad6ceb89447a5 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/operators.move +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/operators.move @@ -11,11 +11,11 @@ module 0x42::operators { x && y || x && !y || !x && y || !x && !y } - fun equality(x: T, y: T): bool { + fun equality(x: T, y: T): bool { x == y } - fun inequality(x: T, y: T): bool { + fun inequality(x: T, y: T): bool { x != y } diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_order.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_order.exp index c47dad9d9a649..813c92392ef60 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_order.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_order.exp @@ -113,3 +113,6 @@ fun pack_unpack::pack6($t0: u8, $t1: u8, $t2: u8): pack_unpack::S { 2: $t3 := pack pack_unpack::S($t2, $t5, $t4) 3: return $t3 } + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_unpack.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_unpack.exp index 7809faaa94493..aa74645f1e360 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_unpack.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/pack_unpack.exp @@ -43,3 +43,6 @@ fun pack_unpack::unpack($t0: pack_unpack::S): (u64, u64) { 3: $t2 := infer($t4) 4: return ($t1, $t2) } + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/reference_conversion.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/reference_conversion.exp index 31dae414fb72d..406be0d625315 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/reference_conversion.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/reference_conversion.exp @@ -40,3 +40,6 @@ fun reference_conversion::use_it(): u64 { 5: $t0 := reference_conversion::deref($t4) 6: return $t0 } + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/spec_construct.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/spec_construct.exp index 5a9371125a768..d304b793db035 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/spec_construct.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/spec_construct.exp @@ -28,3 +28,6 @@ public fun m::foo($t0: &m::S): u8 { 4: $t1 := read_ref($t5) 5: return $t1 } + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/vector.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/vector.exp index 0776edc2f714c..278b6ca0e9eda 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/vector.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/vector.exp @@ -13,3 +13,6 @@ fun vector::create(): vector { 0: $t0 := ["1", "2", "3"] 1: return $t0 } + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/file-format-generator/vector.exp b/third_party/move/move-compiler-v2/tests/file-format-generator/vector.exp index 5c151d72bf392..5a8df708ab8b8 100644 --- a/third_party/move/move-compiler-v2/tests/file-format-generator/vector.exp +++ b/third_party/move/move-compiler-v2/tests/file-format-generator/vector.exp @@ -80,6 +80,8 @@ L1: loc1: u64 L2: loc2: u64 L3: loc3: u64 L4: loc4: u64 +L5: loc5: u64 +L6: loc6: u64 B0: 0: LdU64(0) 1: LdConst[1](Vector(U64): [1, 1, 0, 0, 0, 0, 0, 0, 0]) @@ -91,34 +93,38 @@ B1: 6: ImmBorrowLoc[0](loc0: vector) 7: Call 1vector::is_empty(&vector): bool 8: Not - 9: BrFalse(16) + 9: BrFalse(20) B2: 10: MutBorrowLoc[0](loc0: vector) 11: VecPopBack(5) 12: StLoc[2](loc2: u64) - 13: LdU64(0) - 14: StLoc[1](loc1: u64) - 15: Branch(17) + 13: MoveLoc[1](loc1: u64) + 14: StLoc[3](loc3: u64) + 15: MoveLoc[2](loc2: u64) + 16: StLoc[4](loc4: u64) + 17: LdU64(0) + 18: StLoc[1](loc1: u64) + 19: Branch(21) B3: - 16: Branch(18) + 20: Branch(22) B4: - 17: Branch(6) + 21: Branch(6) B5: - 18: MoveLoc[1](loc1: u64) - 19: StLoc[3](loc3: u64) - 20: LdU64(0) - 21: StLoc[4](loc4: u64) - 22: MoveLoc[3](loc3: u64) - 23: MoveLoc[4](loc4: u64) - 24: Eq - 25: BrFalse(27) + 22: MoveLoc[1](loc1: u64) + 23: StLoc[5](loc5: u64) + 24: LdU64(0) + 25: StLoc[6](loc6: u64) + 26: MoveLoc[5](loc5: u64) + 27: MoveLoc[6](loc6: u64) + 28: Eq + 29: BrFalse(31) B6: - 26: Branch(29) + 30: Branch(33) B7: - 27: LdU64(0) - 28: Abort + 31: LdU64(0) + 32: Abort B8: - 29: Ret + 33: Ret } } ============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_if.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_if.exp index 61c02aec1e09f..f6fb5c095e8a0 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_if.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_if.exp @@ -5,6 +5,7 @@ fun M::tborrow($t0: bool) { var $t1: u64 var $t2: u64 var $t3: &u64 + var $t4: &u64 0: if ($t0) goto 1 else goto 5 1: label L0 2: $t2 := 0 @@ -13,7 +14,8 @@ fun M::tborrow($t0: bool) { 5: label L1 6: label L2 7: $t3 := borrow_local($t1) - 8: return () + 8: $t4 := infer($t3) + 9: return () } @@ -23,6 +25,7 @@ fun M::tcopy($t0: bool) { var $t2: u64 var $t3: u64 var $t4: u64 + var $t5: u64 0: if ($t0) goto 1 else goto 5 1: label L0 2: $t2 := 0 @@ -32,7 +35,8 @@ fun M::tcopy($t0: bool) { 6: label L2 7: $t4 := 1 8: $t3 := +($t1, $t4) - 9: return () + 9: $t5 := infer($t3) + 10: return () } @@ -43,6 +47,7 @@ fun M::tmove($t0: bool) { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: if ($t0) goto 1 else goto 5 1: label L0 2: $t2 := 0 @@ -53,7 +58,8 @@ fun M::tmove($t0: bool) { 7: $t4 := move($t1) 8: $t5 := 1 9: $t3 := +($t4, $t5) - 10: return () + 10: $t6 := infer($t3) + 11: return () } @@ -83,24 +89,27 @@ fun M::tborrow($t0: bool) { var $t1: u64 var $t2: u64 var $t3: &u64 - # before: { no: $t1, $t2, $t3 }, after: { no: $t1, $t2, $t3 } + var $t4: &u64 + # before: { no: $t1, $t2, $t3, $t4 }, after: { no: $t1, $t2, $t3, $t4 } 0: if ($t0) goto 1 else goto 5 - # before: { no: $t1, $t2, $t3 }, after: { no: $t1, $t2, $t3 } + # before: { no: $t1, $t2, $t3, $t4 }, after: { no: $t1, $t2, $t3, $t4 } 1: label L0 - # before: { no: $t1, $t2, $t3 }, after: { no: $t1, $t3 } + # before: { no: $t1, $t2, $t3, $t4 }, after: { no: $t1, $t3, $t4 } 2: $t2 := 0 - # before: { no: $t1, $t3 }, after: { no: $t3 } + # before: { no: $t1, $t3, $t4 }, after: { no: $t3, $t4 } 3: $t1 := infer($t2) - # before: { no: $t3 }, after: { no: $t3 } + # before: { no: $t3, $t4 }, after: { no: $t3, $t4 } 4: goto 6 - # before: { no: $t1, $t2, $t3 }, after: { no: $t1, $t2, $t3 } + # before: { no: $t1, $t2, $t3, $t4 }, after: { no: $t1, $t2, $t3, $t4 } 5: label L1 - # before: { no: $t3 }{ maybe: $t1, $t2 }, after: { no: $t3 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t4 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4 }{ maybe: $t1, $t2 } 6: label L2 - # before: { no: $t3 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } + # before: { no: $t3, $t4 }{ maybe: $t1, $t2 }, after: { no: $t4 }{ maybe: $t1, $t2 } 7: $t3 := borrow_local($t1) + # before: { no: $t4 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } + 8: $t4 := infer($t3) # before: { maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } - 8: return () + 9: return () } @@ -110,26 +119,29 @@ fun M::tcopy($t0: bool) { var $t2: u64 var $t3: u64 var $t4: u64 - # before: { no: $t1, $t2, $t3, $t4 }, after: { no: $t1, $t2, $t3, $t4 } + var $t5: u64 + # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } 0: if ($t0) goto 1 else goto 5 - # before: { no: $t1, $t2, $t3, $t4 }, after: { no: $t1, $t2, $t3, $t4 } + # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } 1: label L0 - # before: { no: $t1, $t2, $t3, $t4 }, after: { no: $t1, $t3, $t4 } + # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t3, $t4, $t5 } 2: $t2 := 0 - # before: { no: $t1, $t3, $t4 }, after: { no: $t3, $t4 } + # before: { no: $t1, $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } 3: $t1 := infer($t2) - # before: { no: $t3, $t4 }, after: { no: $t3, $t4 } + # before: { no: $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } 4: goto 6 - # before: { no: $t1, $t2, $t3, $t4 }, after: { no: $t1, $t2, $t3, $t4 } + # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } 5: label L1 - # before: { no: $t3, $t4 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 } 6: label L2 - # before: { no: $t3, $t4 }{ maybe: $t1, $t2 }, after: { no: $t3 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t5 }{ maybe: $t1, $t2 } 7: $t4 := 1 - # before: { no: $t3 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } + # before: { no: $t3, $t5 }{ maybe: $t1, $t2 }, after: { no: $t5 }{ maybe: $t1, $t2 } 8: $t3 := +($t1, $t4) + # before: { no: $t5 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } + 9: $t5 := infer($t3) # before: { maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } - 9: return () + 10: return () } @@ -140,26 +152,29 @@ fun M::tmove($t0: bool) { var $t3: u64 var $t4: u64 var $t5: u64 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + var $t6: u64 + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 0: if ($t0) goto 1 else goto 5 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 1: label L0 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t3, $t4, $t5, $t6 } 2: $t2 := 0 - # before: { no: $t1, $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } + # before: { no: $t1, $t3, $t4, $t5, $t6 }, after: { no: $t3, $t4, $t5, $t6 } 3: $t1 := infer($t2) - # before: { no: $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } + # before: { no: $t3, $t4, $t5, $t6 }, after: { no: $t3, $t4, $t5, $t6 } 4: goto 6 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 5: label L1 - # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 } 6: label L2 - # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t5 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t5, $t6 }{ maybe: $t1, $t2 } 7: $t4 := move($t1) - # before: { no: $t3, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t6 }{ maybe: $t1, $t2 } 8: $t5 := 1 - # before: { no: $t3 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } + # before: { no: $t3, $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } 9: $t3 := +($t4, $t5) + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } + 10: $t6 := infer($t3) # before: { maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } - 10: return () + 11: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_if_else.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_if_else.exp index 741a8edc91ea5..e8ca33e70873c 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_if_else.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_if_else.exp @@ -7,6 +7,7 @@ fun M::tborrow($t0: bool) { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: if ($t0) goto 1 else goto 3 1: label L0 2: goto 6 @@ -17,7 +18,8 @@ fun M::tborrow($t0: bool) { 7: $t4 := move($t1) 8: $t5 := 1 9: $t3 := +($t4, $t5) - 10: return () + 10: $t6 := infer($t3) + 11: return () } @@ -28,6 +30,7 @@ fun M::tcopy($t0: bool) { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: if ($t0) goto 1 else goto 3 1: label L0 2: goto 6 @@ -38,7 +41,8 @@ fun M::tcopy($t0: bool) { 7: $t4 := move($t1) 8: $t5 := 1 9: $t3 := +($t4, $t5) - 10: return () + 10: $t6 := infer($t3) + 11: return () } @@ -49,6 +53,7 @@ fun M::tmove($t0: bool) { var $t3: u64 var $t4: u64 var $t5: u64 + var $t6: u64 0: if ($t0) goto 1 else goto 3 1: label L0 2: goto 6 @@ -59,7 +64,8 @@ fun M::tmove($t0: bool) { 7: $t4 := move($t1) 8: $t5 := 1 9: $t3 := +($t4, $t5) - 10: return () + 10: $t6 := infer($t3) + 11: return () } @@ -91,28 +97,31 @@ fun M::tborrow($t0: bool) { var $t3: u64 var $t4: u64 var $t5: u64 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + var $t6: u64 + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 0: if ($t0) goto 1 else goto 3 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 1: label L0 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 2: goto 6 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 3: label L1 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t3, $t4, $t5, $t6 } 4: $t2 := 0 - # before: { no: $t1, $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } + # before: { no: $t1, $t3, $t4, $t5, $t6 }, after: { no: $t3, $t4, $t5, $t6 } 5: $t1 := infer($t2) - # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 } 6: label L2 - # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t5 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t5, $t6 }{ maybe: $t1, $t2 } 7: $t4 := move($t1) - # before: { no: $t3, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t6 }{ maybe: $t1, $t2 } 8: $t5 := 1 - # before: { no: $t3 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } + # before: { no: $t3, $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } 9: $t3 := +($t4, $t5) + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } + 10: $t6 := infer($t3) # before: { maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } - 10: return () + 11: return () } @@ -123,28 +132,31 @@ fun M::tcopy($t0: bool) { var $t3: u64 var $t4: u64 var $t5: u64 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + var $t6: u64 + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 0: if ($t0) goto 1 else goto 3 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 1: label L0 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 2: goto 6 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 3: label L1 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t3, $t4, $t5, $t6 } 4: $t2 := 0 - # before: { no: $t1, $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } + # before: { no: $t1, $t3, $t4, $t5, $t6 }, after: { no: $t3, $t4, $t5, $t6 } 5: $t1 := infer($t2) - # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 } 6: label L2 - # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t5 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t5, $t6 }{ maybe: $t1, $t2 } 7: $t4 := move($t1) - # before: { no: $t3, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t6 }{ maybe: $t1, $t2 } 8: $t5 := 1 - # before: { no: $t3 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } + # before: { no: $t3, $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } 9: $t3 := +($t4, $t5) + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } + 10: $t6 := infer($t3) # before: { maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } - 10: return () + 11: return () } @@ -155,26 +167,29 @@ fun M::tmove($t0: bool) { var $t3: u64 var $t4: u64 var $t5: u64 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + var $t6: u64 + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 0: if ($t0) goto 1 else goto 3 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 1: label L0 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 2: goto 6 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 3: label L1 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t3, $t4, $t5, $t6 } 4: $t2 := 0 - # before: { no: $t1, $t3, $t4, $t5 }, after: { no: $t3, $t4, $t5 } + # before: { no: $t1, $t3, $t4, $t5, $t6 }, after: { no: $t3, $t4, $t5, $t6 } 5: $t1 := infer($t2) - # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 } 6: label L2 - # before: { no: $t3, $t4, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3, $t5 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t4, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t5, $t6 }{ maybe: $t1, $t2 } 7: $t4 := move($t1) - # before: { no: $t3, $t5 }{ maybe: $t1, $t2 }, after: { no: $t3 }{ maybe: $t1, $t2 } + # before: { no: $t3, $t5, $t6 }{ maybe: $t1, $t2 }, after: { no: $t3, $t6 }{ maybe: $t1, $t2 } 8: $t5 := 1 - # before: { no: $t3 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } + # before: { no: $t3, $t6 }{ maybe: $t1, $t2 }, after: { no: $t6 }{ maybe: $t1, $t2 } 9: $t3 := +($t4, $t5) + # before: { no: $t6 }{ maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } + 10: $t6 := infer($t3) # before: { maybe: $t1, $t2 }, after: { maybe: $t1, $t2 } - 10: return () + 11: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_loop.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_loop.exp index 6792c32ed6601..175d7515003fb 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_loop.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_loop.exp @@ -5,15 +5,17 @@ fun M::tborrow1() { var $t0: u64 var $t1: &u64 var $t2: &u64 - var $t3: u64 + var $t3: &u64 + var $t4: u64 0: label L0 1: $t1 := borrow_local($t0) 2: $t2 := move($t1) - 3: $t3 := 0 - 4: $t0 := infer($t3) - 5: goto 0 - 6: label L1 - 7: return () + 3: $t3 := infer($t2) + 4: $t4 := 0 + 5: $t0 := infer($t4) + 6: goto 0 + 7: label L1 + 8: return () } @@ -22,23 +24,25 @@ fun M::tborrow2($t0: bool) { var $t1: u64 var $t2: &u64 var $t3: &u64 - var $t4: u64 + var $t4: &u64 var $t5: u64 + var $t6: u64 0: label L0 1: $t2 := borrow_local($t1) 2: $t3 := move($t2) - 3: if ($t0) goto 4 else goto 8 - 4: label L2 - 5: $t4 := 0 - 6: $t1 := infer($t4) - 7: goto 9 - 8: label L3 - 9: label L4 - 10: goto 12 - 11: goto 0 - 12: label L1 - 13: $t5 := infer($t1) - 14: return () + 3: $t4 := infer($t3) + 4: if ($t0) goto 5 else goto 9 + 5: label L2 + 6: $t5 := 0 + 7: $t1 := infer($t5) + 8: goto 10 + 9: label L3 + 10: label L4 + 11: goto 13 + 12: goto 0 + 13: label L1 + 14: $t6 := infer($t1) + 15: return () } @@ -126,21 +130,24 @@ fun M::tborrow1() { var $t0: u64 var $t1: &u64 var $t2: &u64 - var $t3: u64 - # before: { maybe: $t0, $t1, $t2, $t3 }, after: { maybe: $t0, $t1, $t2, $t3 } + var $t3: &u64 + var $t4: u64 + # before: { maybe: $t0, $t1, $t2, $t3, $t4 }, after: { maybe: $t0, $t1, $t2, $t3, $t4 } 0: label L0 - # before: { maybe: $t0, $t1, $t2, $t3 }, after: { maybe: $t0, $t2, $t3 } + # before: { maybe: $t0, $t1, $t2, $t3, $t4 }, after: { maybe: $t0, $t2, $t3, $t4 } 1: $t1 := borrow_local($t0) - # before: { maybe: $t0, $t2, $t3 }, after: { maybe: $t0, $t3 } + # before: { maybe: $t0, $t2, $t3, $t4 }, after: { maybe: $t0, $t3, $t4 } 2: $t2 := move($t1) - # before: { maybe: $t0, $t3 }, after: { maybe: $t0 } - 3: $t3 := 0 + # before: { maybe: $t0, $t3, $t4 }, after: { maybe: $t0, $t4 } + 3: $t3 := infer($t2) + # before: { maybe: $t0, $t4 }, after: { maybe: $t0 } + 4: $t4 := 0 # before: { maybe: $t0 }, after: all initialized - 4: $t0 := infer($t3) + 5: $t0 := infer($t4) # before: all initialized, after: all initialized - 5: goto 0 - 6: label L1 - 7: return () + 6: goto 0 + 7: label L1 + 8: return () } @@ -149,37 +156,40 @@ fun M::tborrow2($t0: bool) { var $t1: u64 var $t2: &u64 var $t3: &u64 - var $t4: u64 + var $t4: &u64 var $t5: u64 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + var $t6: u64 + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t2, $t3, $t4, $t5, $t6 } 0: label L0 - # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t3, $t4, $t5 } + # before: { no: $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t3, $t4, $t5, $t6 } 1: $t2 := borrow_local($t1) - # before: { no: $t1, $t3, $t4, $t5 }, after: { no: $t1, $t4, $t5 } + # before: { no: $t1, $t3, $t4, $t5, $t6 }, after: { no: $t1, $t4, $t5, $t6 } 2: $t3 := move($t2) - # before: { no: $t1, $t4, $t5 }, after: { no: $t1, $t4, $t5 } - 3: if ($t0) goto 4 else goto 8 - # before: { no: $t1, $t4, $t5 }, after: { no: $t1, $t4, $t5 } - 4: label L2 - # before: { no: $t1, $t4, $t5 }, after: { no: $t1, $t5 } - 5: $t4 := 0 - # before: { no: $t1, $t5 }, after: { no: $t5 } - 6: $t1 := infer($t4) - # before: { no: $t5 }, after: { no: $t5 } - 7: goto 9 - # before: { no: $t1, $t4, $t5 }, after: { no: $t1, $t4, $t5 } - 8: label L3 - # before: { no: $t5 }{ maybe: $t1, $t4 }, after: { no: $t5 }{ maybe: $t1, $t4 } - 9: label L4 - # before: { no: $t5 }{ maybe: $t1, $t4 }, after: { no: $t5 }{ maybe: $t1, $t4 } - 10: goto 12 - 11: goto 0 - # before: { no: $t5 }{ maybe: $t1, $t4 }, after: { no: $t5 }{ maybe: $t1, $t4 } - 12: label L1 - # before: { no: $t5 }{ maybe: $t1, $t4 }, after: { maybe: $t1, $t4 } - 13: $t5 := infer($t1) - # before: { maybe: $t1, $t4 }, after: { maybe: $t1, $t4 } - 14: return () + # before: { no: $t1, $t4, $t5, $t6 }, after: { no: $t1, $t5, $t6 } + 3: $t4 := infer($t3) + # before: { no: $t1, $t5, $t6 }, after: { no: $t1, $t5, $t6 } + 4: if ($t0) goto 5 else goto 9 + # before: { no: $t1, $t5, $t6 }, after: { no: $t1, $t5, $t6 } + 5: label L2 + # before: { no: $t1, $t5, $t6 }, after: { no: $t1, $t6 } + 6: $t5 := 0 + # before: { no: $t1, $t6 }, after: { no: $t6 } + 7: $t1 := infer($t5) + # before: { no: $t6 }, after: { no: $t6 } + 8: goto 10 + # before: { no: $t1, $t5, $t6 }, after: { no: $t1, $t5, $t6 } + 9: label L3 + # before: { no: $t6 }{ maybe: $t1, $t5 }, after: { no: $t6 }{ maybe: $t1, $t5 } + 10: label L4 + # before: { no: $t6 }{ maybe: $t1, $t5 }, after: { no: $t6 }{ maybe: $t1, $t5 } + 11: goto 13 + 12: goto 0 + # before: { no: $t6 }{ maybe: $t1, $t5 }, after: { no: $t6 }{ maybe: $t1, $t5 } + 13: label L1 + # before: { no: $t6 }{ maybe: $t1, $t5 }, after: { maybe: $t1, $t5 } + 14: $t6 := infer($t1) + # before: { maybe: $t1, $t5 }, after: { maybe: $t1, $t5 } + 15: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_simple.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_simple.exp index 16b217d83db31..89b580d92ae0c 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_simple.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_simple.exp @@ -4,11 +4,13 @@ fun M::tborrow() { var $t0: u64 var $t1: &u64 - var $t2: M::S - var $t3: &M::S + var $t2: &u64 + var $t3: M::S + var $t4: &M::S 0: $t1 := borrow_local($t0) - 1: $t3 := borrow_local($t2) - 2: return () + 1: $t2 := infer($t1) + 2: $t4 := borrow_local($t3) + 3: return () } @@ -17,12 +19,14 @@ fun M::tcopy() { var $t0: u64 var $t1: u64 var $t2: u64 - var $t3: M::S + var $t3: u64 var $t4: M::S + var $t5: M::S 0: $t2 := 1 1: $t1 := +($t0, $t2) - 2: $t4 := copy($t3) - 3: return () + 2: $t3 := infer($t1) + 3: $t5 := copy($t4) + 4: return () } @@ -32,13 +36,15 @@ fun M::tmove() { var $t1: u64 var $t2: u64 var $t3: u64 - var $t4: M::S + var $t4: u64 var $t5: M::S + var $t6: M::S 0: $t2 := move($t0) 1: $t3 := 1 2: $t1 := +($t2, $t3) - 3: $t5 := infer($t4) - 4: return () + 3: $t4 := infer($t1) + 4: $t6 := infer($t5) + 5: return () } @@ -85,14 +91,17 @@ error: use of unassigned local `s` fun M::tborrow() { var $t0: u64 var $t1: &u64 - var $t2: M::S - var $t3: &M::S - # before: { no: $t0, $t1, $t2, $t3 }, after: { no: $t0, $t2, $t3 } + var $t2: &u64 + var $t3: M::S + var $t4: &M::S + # before: { no: $t0, $t1, $t2, $t3, $t4 }, after: { no: $t0, $t2, $t3, $t4 } 0: $t1 := borrow_local($t0) - # before: { no: $t0, $t2, $t3 }, after: { no: $t0, $t2 } - 1: $t3 := borrow_local($t2) - # before: { no: $t0, $t2 }, after: { no: $t0, $t2 } - 2: return () + # before: { no: $t0, $t2, $t3, $t4 }, after: { no: $t0, $t3, $t4 } + 1: $t2 := infer($t1) + # before: { no: $t0, $t3, $t4 }, after: { no: $t0, $t3 } + 2: $t4 := borrow_local($t3) + # before: { no: $t0, $t3 }, after: { no: $t0, $t3 } + 3: return () } @@ -101,16 +110,19 @@ fun M::tcopy() { var $t0: u64 var $t1: u64 var $t2: u64 - var $t3: M::S + var $t3: u64 var $t4: M::S - # before: { no: $t0, $t1, $t2, $t3, $t4 }, after: { no: $t0, $t1, $t3, $t4 } + var $t5: M::S + # before: { no: $t0, $t1, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t1, $t3, $t4, $t5 } 0: $t2 := 1 - # before: { no: $t0, $t1, $t3, $t4 }, after: { no: $t0, $t3, $t4 } + # before: { no: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t0, $t3, $t4, $t5 } 1: $t1 := +($t0, $t2) - # before: { no: $t0, $t3, $t4 }, after: { no: $t0, $t3 } - 2: $t4 := copy($t3) - # before: { no: $t0, $t3 }, after: { no: $t0, $t3 } - 3: return () + # before: { no: $t0, $t3, $t4, $t5 }, after: { no: $t0, $t4, $t5 } + 2: $t3 := infer($t1) + # before: { no: $t0, $t4, $t5 }, after: { no: $t0, $t4 } + 3: $t5 := copy($t4) + # before: { no: $t0, $t4 }, after: { no: $t0, $t4 } + 4: return () } @@ -120,16 +132,19 @@ fun M::tmove() { var $t1: u64 var $t2: u64 var $t3: u64 - var $t4: M::S + var $t4: u64 var $t5: M::S - # before: { no: $t0, $t1, $t2, $t3, $t4, $t5 }, after: { no: $t0, $t1, $t3, $t4, $t5 } + var $t6: M::S + # before: { no: $t0, $t1, $t2, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t1, $t3, $t4, $t5, $t6 } 0: $t2 := move($t0) - # before: { no: $t0, $t1, $t3, $t4, $t5 }, after: { no: $t0, $t1, $t4, $t5 } + # before: { no: $t0, $t1, $t3, $t4, $t5, $t6 }, after: { no: $t0, $t1, $t4, $t5, $t6 } 1: $t3 := 1 - # before: { no: $t0, $t1, $t4, $t5 }, after: { no: $t0, $t4, $t5 } + # before: { no: $t0, $t1, $t4, $t5, $t6 }, after: { no: $t0, $t4, $t5, $t6 } 2: $t1 := +($t2, $t3) - # before: { no: $t0, $t4, $t5 }, after: { no: $t0, $t4 } - 3: $t5 := infer($t4) - # before: { no: $t0, $t4 }, after: { no: $t0, $t4 } - 4: return () + # before: { no: $t0, $t4, $t5, $t6 }, after: { no: $t0, $t5, $t6 } + 3: $t4 := infer($t1) + # before: { no: $t0, $t5, $t6 }, after: { no: $t0, $t5 } + 4: $t6 := infer($t5) + # before: { no: $t0, $t5 }, after: { no: $t0, $t5 } + 5: return () } diff --git a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_while.exp b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_while.exp index 467127570e530..89f42d1c54a9e 100644 --- a/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_while.exp +++ b/third_party/move/move-compiler-v2/tests/uninit-use-checker/v1-locals/use_before_assign_while.exp @@ -5,21 +5,23 @@ fun M::tborrow1($t0: bool) { var $t1: u64 var $t2: &u64 var $t3: &u64 - var $t4: u64 + var $t4: &u64 + var $t5: u64 0: label L0 - 1: if ($t0) goto 2 else goto 8 + 1: if ($t0) goto 2 else goto 9 2: label L2 3: $t2 := borrow_local($t1) 4: $t3 := move($t2) - 5: $t4 := 0 - 6: $t1 := infer($t4) - 7: goto 10 - 8: label L3 - 9: goto 12 - 10: label L4 - 11: goto 0 - 12: label L1 - 13: return () + 5: $t4 := infer($t3) + 6: $t5 := 0 + 7: $t1 := infer($t5) + 8: goto 11 + 9: label L3 + 10: goto 13 + 11: label L4 + 12: goto 0 + 13: label L1 + 14: return () } @@ -28,27 +30,29 @@ fun M::tborrow2($t0: bool) { var $t1: u64 var $t2: &u64 var $t3: &u64 - var $t4: u64 + var $t4: &u64 + var $t5: u64 0: label L0 - 1: if ($t0) goto 2 else goto 14 + 1: if ($t0) goto 2 else goto 15 2: label L2 3: $t2 := borrow_local($t1) 4: $t3 := move($t2) - 5: if ($t0) goto 6 else goto 10 - 6: label L5 - 7: $t4 := 0 - 8: $t1 := infer($t4) - 9: goto 11 - 10: label L6 - 11: label L7 - 12: goto 18 - 13: goto 16 - 14: label L3 - 15: goto 18 - 16: label L4 - 17: goto 0 - 18: label L1 - 19: return () + 5: $t4 := infer($t3) + 6: if ($t0) goto 7 else goto 11 + 7: label L5 + 8: $t5 := 0 + 9: $t1 := infer($t5) + 10: goto 12 + 11: label L6 + 12: label L7 + 13: goto 19 + 14: goto 17 + 15: label L3 + 16: goto 19 + 17: label L4 + 18: goto 0 + 19: label L1 + 20: return () } @@ -144,35 +148,38 @@ fun M::tborrow1($t0: bool) { var $t1: u64 var $t2: &u64 var $t3: &u64 - var $t4: u64 - # before: { maybe: $t1, $t2, $t3, $t4 }, after: { maybe: $t1, $t2, $t3, $t4 } + var $t4: &u64 + var $t5: u64 + # before: { maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t2, $t3, $t4, $t5 } 0: label L0 - # before: { maybe: $t1, $t2, $t3, $t4 }, after: { maybe: $t1, $t2, $t3, $t4 } - 1: if ($t0) goto 2 else goto 8 - # before: { maybe: $t1, $t2, $t3, $t4 }, after: { maybe: $t1, $t2, $t3, $t4 } + # before: { maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t2, $t3, $t4, $t5 } + 1: if ($t0) goto 2 else goto 9 + # before: { maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t2, $t3, $t4, $t5 } 2: label L2 - # before: { maybe: $t1, $t2, $t3, $t4 }, after: { maybe: $t1, $t3, $t4 } + # before: { maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t3, $t4, $t5 } 3: $t2 := borrow_local($t1) - # before: { maybe: $t1, $t3, $t4 }, after: { maybe: $t1, $t4 } + # before: { maybe: $t1, $t3, $t4, $t5 }, after: { maybe: $t1, $t4, $t5 } 4: $t3 := move($t2) - # before: { maybe: $t1, $t4 }, after: { maybe: $t1 } - 5: $t4 := 0 + # before: { maybe: $t1, $t4, $t5 }, after: { maybe: $t1, $t5 } + 5: $t4 := infer($t3) + # before: { maybe: $t1, $t5 }, after: { maybe: $t1 } + 6: $t5 := 0 # before: { maybe: $t1 }, after: all initialized - 6: $t1 := infer($t4) + 7: $t1 := infer($t5) # before: all initialized, after: all initialized - 7: goto 10 - # before: { maybe: $t1, $t2, $t3, $t4 }, after: { maybe: $t1, $t2, $t3, $t4 } - 8: label L3 - # before: { maybe: $t1, $t2, $t3, $t4 }, after: { maybe: $t1, $t2, $t3, $t4 } - 9: goto 12 + 8: goto 11 + # before: { maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t2, $t3, $t4, $t5 } + 9: label L3 + # before: { maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t2, $t3, $t4, $t5 } + 10: goto 13 # before: all initialized, after: all initialized - 10: label L4 + 11: label L4 # before: all initialized, after: all initialized - 11: goto 0 - # before: { maybe: $t1, $t2, $t3, $t4 }, after: { maybe: $t1, $t2, $t3, $t4 } - 12: label L1 - # before: { maybe: $t1, $t2, $t3, $t4 }, after: { maybe: $t1, $t2, $t3, $t4 } - 13: return () + 12: goto 0 + # before: { maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t2, $t3, $t4, $t5 } + 13: label L1 + # before: { maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t2, $t3, $t4, $t5 } + 14: return () } @@ -181,44 +188,47 @@ fun M::tborrow2($t0: bool) { var $t1: u64 var $t2: &u64 var $t3: &u64 - var $t4: u64 - # before: { no: $t1, $t2, $t3, $t4 }, after: { no: $t1, $t2, $t3, $t4 } + var $t4: &u64 + var $t5: u64 + # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } 0: label L0 - # before: { no: $t1, $t2, $t3, $t4 }, after: { no: $t1, $t2, $t3, $t4 } - 1: if ($t0) goto 2 else goto 14 - # before: { no: $t1, $t2, $t3, $t4 }, after: { no: $t1, $t2, $t3, $t4 } + # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + 1: if ($t0) goto 2 else goto 15 + # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } 2: label L2 - # before: { no: $t1, $t2, $t3, $t4 }, after: { no: $t1, $t3, $t4 } + # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t3, $t4, $t5 } 3: $t2 := borrow_local($t1) - # before: { no: $t1, $t3, $t4 }, after: { no: $t1, $t4 } + # before: { no: $t1, $t3, $t4, $t5 }, after: { no: $t1, $t4, $t5 } 4: $t3 := move($t2) - # before: { no: $t1, $t4 }, after: { no: $t1, $t4 } - 5: if ($t0) goto 6 else goto 10 - # before: { no: $t1, $t4 }, after: { no: $t1, $t4 } - 6: label L5 - # before: { no: $t1, $t4 }, after: { no: $t1 } - 7: $t4 := 0 + # before: { no: $t1, $t4, $t5 }, after: { no: $t1, $t5 } + 5: $t4 := infer($t3) + # before: { no: $t1, $t5 }, after: { no: $t1, $t5 } + 6: if ($t0) goto 7 else goto 11 + # before: { no: $t1, $t5 }, after: { no: $t1, $t5 } + 7: label L5 + # before: { no: $t1, $t5 }, after: { no: $t1 } + 8: $t5 := 0 # before: { no: $t1 }, after: all initialized - 8: $t1 := infer($t4) + 9: $t1 := infer($t5) # before: all initialized, after: all initialized - 9: goto 11 - # before: { no: $t1, $t4 }, after: { no: $t1, $t4 } - 10: label L6 - # before: { maybe: $t1, $t4 }, after: { maybe: $t1, $t4 } - 11: label L7 - # before: { maybe: $t1, $t4 }, after: { maybe: $t1, $t4 } - 12: goto 18 - 13: goto 16 - # before: { no: $t1, $t2, $t3, $t4 }, after: { no: $t1, $t2, $t3, $t4 } - 14: label L3 - # before: { no: $t1, $t2, $t3, $t4 }, after: { no: $t1, $t2, $t3, $t4 } - 15: goto 18 - 16: label L4 - 17: goto 0 - # before: { maybe: $t1, $t2, $t3, $t4 }, after: { maybe: $t1, $t2, $t3, $t4 } - 18: label L1 - # before: { maybe: $t1, $t2, $t3, $t4 }, after: { maybe: $t1, $t2, $t3, $t4 } - 19: return () + 10: goto 12 + # before: { no: $t1, $t5 }, after: { no: $t1, $t5 } + 11: label L6 + # before: { maybe: $t1, $t5 }, after: { maybe: $t1, $t5 } + 12: label L7 + # before: { maybe: $t1, $t5 }, after: { maybe: $t1, $t5 } + 13: goto 19 + 14: goto 17 + # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + 15: label L3 + # before: { no: $t1, $t2, $t3, $t4, $t5 }, after: { no: $t1, $t2, $t3, $t4, $t5 } + 16: goto 19 + 17: label L4 + 18: goto 0 + # before: { maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t2, $t3, $t4, $t5 } + 19: label L1 + # before: { maybe: $t1, $t2, $t3, $t4, $t5 }, after: { maybe: $t1, $t2, $t3, $t4, $t5 } + 20: return () } diff --git a/third_party/move/move-compiler-v2/tests/variable-coalescing/inlining1.exp b/third_party/move/move-compiler-v2/tests/variable-coalescing/inlining1.exp index ed25e5df77291..39832e3a20b40 100644 --- a/third_party/move/move-compiler-v2/tests/variable-coalescing/inlining1.exp +++ b/third_party/move/move-compiler-v2/tests/variable-coalescing/inlining1.exp @@ -5,10 +5,12 @@ public fun Test::test(): u64 { var $t0: u64 var $t1: u64 var $t2: u64 + var $t3: u64 0: $t2 := 10 1: $t1 := infer($t2) - 2: $t0 := 3 - 3: return $t0 + 2: $t3 := infer($t1) + 3: $t0 := 3 + 4: return $t0 } ============ after DeadStoreElimination: ================ @@ -18,6 +20,7 @@ public fun Test::test(): u64 { var $t0: u64 var $t1: u64 [unused] var $t2: u64 [unused] + var $t3: u64 [unused] 0: $t0 := 3 1: return $t0 } @@ -29,6 +32,7 @@ public fun Test::test(): u64 { var $t0: u64 var $t1: u64 [unused] var $t2: u64 [unused] + var $t3: u64 [unused] # live vars: # events: b:$t0 0: $t0 := 3 @@ -44,6 +48,7 @@ public fun Test::test(): u64 { var $t0: u64 var $t1: u64 [unused] var $t2: u64 [unused] + var $t3: u64 [unused] 0: $t0 := 3 1: return $t0 } @@ -55,6 +60,7 @@ public fun Test::test(): u64 { var $t0: u64 var $t1: u64 [unused] var $t2: u64 [unused] + var $t3: u64 [unused] 0: $t0 := 3 1: return $t0 } From 1999914cde691064430c5d747413f23ea5c476d4 Mon Sep 17 00:00:00 2001 From: Vineeth Kashyap Date: Wed, 10 Apr 2024 12:31:20 -0400 Subject: [PATCH 4/8] Addressing code review comments. --- .../tests/bytecode-generator/wildcard1.exp | 2 +- .../tests/bytecode-generator/wildcard5.exp | 35 +++++++++++++ .../tests/bytecode-generator/wildcard5.move | 11 ++++ .../tests/bytecode-generator/wildcard6.exp | 39 ++++++++++++++ .../tests/bytecode-generator/wildcard6.move | 7 +++ .../tests/bytecode-generator/wildcard7.exp | 52 +++++++++++++++++++ .../tests/bytecode-generator/wildcard7.move | 9 ++++ .../checking/typing/v1-commands/pop_weird.exp | 2 +- .../move-model/src/builder/exp_builder.rs | 2 +- 9 files changed, 156 insertions(+), 3 deletions(-) create mode 100644 third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard5.exp create mode 100644 third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard5.move create mode 100644 third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard6.exp create mode 100644 third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard6.move create mode 100644 third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard7.exp create mode 100644 third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard7.move diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard1.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard1.exp index 50c25a1cc25c9..413cd6c8f2ca3 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard1.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard1.exp @@ -1,6 +1,6 @@ Diagnostics: -error: the left-hand side has 2 items but the right-hand side provided 1 +error: the left-hand side has 1 item but the right-hand side provided 2 ┌─ tests/bytecode-generator/wildcard1.move:7:13 │ 7 │ let _ = tup(); diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard5.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard5.exp new file mode 100644 index 0000000000000..5964ecaf52dfd --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard5.exp @@ -0,0 +1,35 @@ +// -- Model dump before bytecode pipeline +module 0xc0ffee::m { + struct S { + x: u64, + y: u64, + } + public fun test() { + { + let s: m::S = pack m::S(3, 4); + { + let m::S{ x: _, y: _ }: m::S = s; + Tuple() + } + } + } +} // end 0xc0ffee::m + +============ initial bytecode ================ + +[variant baseline] +public fun m::test() { + var $t0: m::S + var $t1: u64 + var $t2: u64 + var $t3: u64 + var $t4: u64 + 0: $t1 := 3 + 1: $t2 := 4 + 2: $t0 := pack m::S($t1, $t2) + 3: ($t3, $t4) := unpack m::S($t0) + 4: return () +} + + +============ bytecode verification succeeded ======== diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard5.move b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard5.move new file mode 100644 index 0000000000000..b322385c1a16c --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard5.move @@ -0,0 +1,11 @@ +module 0xc0ffee::m { + struct S { + x: u64, + y: u64 + } + + public fun test() { + let s = S {x: 3, y: 4}; + let S {x: _, y: _} = s; + } +} diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard6.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard6.exp new file mode 100644 index 0000000000000..a2fcf0f8df3e3 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard6.exp @@ -0,0 +1,39 @@ +// -- Model dump before bytecode pipeline +module 0xc0ffee::m { + public fun test2(): u64 { + { + let x: u64 = 40; + { + let (y: u64, _): (u64, u64) = Tuple(Move(x), x); + y + } + } + } +} // end 0xc0ffee::m + +============ initial bytecode ================ + +[variant baseline] +public fun m::test2(): u64 { + var $t0: u64 + var $t1: u64 + var $t2: u64 + var $t3: u64 + var $t4: u64 + 0: $t1 := 40 + 1: $t3 := move($t1) + 2: $t2 := infer($t3) + 3: $t4 := infer($t1) + 4: $t0 := infer($t2) + 5: return $t0 +} + + +Diagnostics: +error: cannot move local `x` since it is still in use + ┌─ tests/bytecode-generator/wildcard6.move:4:23 + │ +4 │ let (y, _) = (move x, x); + │ ------ ^^^^^^ attempted to move here + │ │ + │ used here diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard6.move b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard6.move new file mode 100644 index 0000000000000..99334951cf2bf --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard6.move @@ -0,0 +1,7 @@ +module 0xc0ffee::m { + public fun test2(): u64 { + let x = 40; + let (y, _) = (move x, x); + y + } +} diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard7.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard7.exp new file mode 100644 index 0000000000000..1e6874b74166b --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard7.exp @@ -0,0 +1,52 @@ + +Diagnostics: +warning: Unused local variable `q`. Consider removing or prefixing with an underscore: `_q` + ┌─ tests/bytecode-generator/wildcard7.move:6:17 + │ +6 │ let (_, q) = (x, z); + │ ^ + +// -- Model dump before bytecode pipeline +module 0xc0ffee::m { + public fun test(): u8 { + { + let x: u8 = 40; + { + let y: u8 = Move(x); + { + let (_, q: u64): (u8, u64) = Tuple(x, 30); + y + } + } + } + } +} // end 0xc0ffee::m + +============ initial bytecode ================ + +[variant baseline] +public fun m::test(): u8 { + var $t0: u8 + var $t1: u8 + var $t2: u8 + var $t3: u64 + var $t4: u8 + var $t5: u64 + 0: $t1 := 40 + 1: $t2 := move($t1) + 2: $t4 := infer($t1) + 3: $t5 := 30 + 4: $t3 := infer($t5) + 5: $t0 := infer($t2) + 6: return $t0 +} + + +Diagnostics: +error: cannot move local `x` since it is still in use + ┌─ tests/bytecode-generator/wildcard7.move:5:17 + │ +5 │ let y = move x; + │ ^^^^^^ attempted to move here +6 │ let (_, q) = (x, z); + │ ------ used here diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard7.move b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard7.move new file mode 100644 index 0000000000000..9cc04703832cf --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard7.move @@ -0,0 +1,9 @@ +module 0xc0ffee::m { + public fun test(): u8 { + let x = 40; + let z = 30; + let y = move x; + let (_, q) = (x, z); + y + } +} diff --git a/third_party/move/move-compiler-v2/tests/checking/typing/v1-commands/pop_weird.exp b/third_party/move/move-compiler-v2/tests/checking/typing/v1-commands/pop_weird.exp index a0e8f74d54ae2..b79b50668a2bd 100644 --- a/third_party/move/move-compiler-v2/tests/checking/typing/v1-commands/pop_weird.exp +++ b/third_party/move/move-compiler-v2/tests/checking/typing/v1-commands/pop_weird.exp @@ -6,7 +6,7 @@ error: the left-hand side has 2 items but the right-hand side provided 0 13 │ (_, _) = (); │ ^^^^^^ -error: the left-hand side has 0 items but the right-hand side provided 1 +error: the left-hand side has 1 item but the right-hand side provided 0 ┌─ tests/checking/typing/v1-commands/pop_weird.move:14:9 │ 14 │ (_) = (); diff --git a/third_party/move/move-model/src/builder/exp_builder.rs b/third_party/move/move-model/src/builder/exp_builder.rs index 4b848c6f99a32..944620fcf7b13 100644 --- a/third_party/move/move-model/src/builder/exp_builder.rs +++ b/third_party/move/move-model/src/builder/exp_builder.rs @@ -2226,7 +2226,7 @@ impl<'env, 'translator, 'module_translator> ExpTranslator<'env, 'translator, 'mo let specialized_expected_type = self.subs.specialize(expected_type); if let Type::Tuple(tys) = specialized_expected_type { if tys.len() != 1 { - self.error(loc, &context.arity_mismatch(false, 1, tys.len())); + self.error(loc, &context.arity_mismatch(false, tys.len(), 1)); return self.new_error_pat(loc); } } From 6be0e77b0c3b6bea244572dc1158d27b189e1fd5 Mon Sep 17 00:00:00 2001 From: Vineeth Kashyap Date: Wed, 10 Apr 2024 12:40:06 -0400 Subject: [PATCH 5/8] rebase update --- .../moved_var_not_simplified3.exp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/moved_var_not_simplified3.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/moved_var_not_simplified3.exp index 3755b319d9967..fa669c34cd583 100644 --- a/third_party/move/move-compiler-v2/tests/bytecode-generator/moved_var_not_simplified3.exp +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/moved_var_not_simplified3.exp @@ -21,11 +21,20 @@ public fun m::test(): u8 { var $t0: u8 var $t1: u8 var $t2: u8 + var $t3: u8 0: $t1 := 40 1: $t2 := move($t1) - 2: $t0 := infer($t2) - 3: return $t0 + 2: $t3 := infer($t1) + 3: $t0 := infer($t2) + 4: return $t0 } -============ bytecode verification succeeded ======== +Diagnostics: +error: cannot move local `x` since it is still in use + ┌─ tests/bytecode-generator/moved_var_not_simplified3.move:4:17 + │ +4 │ let y = move x; + │ ^^^^^^ attempted to move here +5 │ let _ = x; + │ - used here From 596d247b34a87ec96b1411f4751ac0387a032b9a Mon Sep 17 00:00:00 2001 From: Vineeth Kashyap Date: Wed, 10 Apr 2024 15:23:04 -0400 Subject: [PATCH 6/8] Another test --- .../tests/bytecode-generator/wildcard8.exp | 32 +++++++++++++++++++ .../tests/bytecode-generator/wildcard8.move | 6 ++++ 2 files changed, 38 insertions(+) create mode 100644 third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard8.exp create mode 100644 third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard8.move diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard8.exp b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard8.exp new file mode 100644 index 0000000000000..effcb2e6745e9 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard8.exp @@ -0,0 +1,32 @@ +// -- Model dump before bytecode pipeline +module 0xc0ffee::m { + public fun test() { + { + let x: u64; + { + let (_, _): (u64, u64) = Tuple(x, x); + Tuple() + } + } + } +} // end 0xc0ffee::m + +============ initial bytecode ================ + +[variant baseline] +public fun m::test() { + var $t0: u64 + var $t1: u64 + var $t2: u64 + 0: $t1 := infer($t0) + 1: $t2 := infer($t0) + 2: return () +} + + +Diagnostics: +error: use of unassigned local `x` + ┌─ tests/bytecode-generator/wildcard8.move:4:13 + │ +4 │ let (_, _) = (x, x); + │ ^^^^^^ diff --git a/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard8.move b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard8.move new file mode 100644 index 0000000000000..548be15785bc6 --- /dev/null +++ b/third_party/move/move-compiler-v2/tests/bytecode-generator/wildcard8.move @@ -0,0 +1,6 @@ +module 0xc0ffee::m { + public fun test() { + let x: u64; + let (_, _) = (x, x); + } +} From a414bf41e5ff43566423a46c45f4a592cede0ebd Mon Sep 17 00:00:00 2001 From: Vineeth Kashyap Date: Fri, 12 Apr 2024 14:42:35 -0400 Subject: [PATCH 7/8] Adding new wildcard tests back to v1 --- .../move/move-compiler-v2/tests/v1.matched | 8 +++++++ .../v2_tests/bytecode-generator/wildcard1.exp | 9 ++++++++ .../bytecode-generator/wildcard1.move | 9 ++++++++ .../v2_tests/bytecode-generator/wildcard2.exp | 8 +++++++ .../bytecode-generator/wildcard2.move | 6 +++++ .../v2_tests/bytecode-generator/wildcard3.exp | 22 +++++++++++++++++++ .../bytecode-generator/wildcard3.move | 12 ++++++++++ .../v2_tests/bytecode-generator/wildcard4.exp | 9 ++++++++ .../bytecode-generator/wildcard4.move | 9 ++++++++ .../bytecode-generator/wildcard5.move | 11 ++++++++++ .../v2_tests/bytecode-generator/wildcard6.exp | 9 ++++++++ .../bytecode-generator/wildcard6.move | 7 ++++++ .../v2_tests/bytecode-generator/wildcard7.exp | 17 ++++++++++++++ .../bytecode-generator/wildcard7.move | 9 ++++++++ .../v2_tests/bytecode-generator/wildcard8.exp | 16 ++++++++++++++ .../bytecode-generator/wildcard8.move | 6 +++++ 16 files changed, 167 insertions(+) create mode 100644 third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard1.exp create mode 100644 third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard1.move create mode 100644 third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard2.exp create mode 100644 third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard2.move create mode 100644 third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard3.exp create mode 100644 third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard3.move create mode 100644 third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard4.exp create mode 100644 third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard4.move create mode 100644 third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard5.move create mode 100644 third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard6.exp create mode 100644 third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard6.move create mode 100644 third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard7.exp create mode 100644 third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard7.move create mode 100644 third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard8.exp create mode 100644 third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard8.move diff --git a/third_party/move/move-compiler-v2/tests/v1.matched b/third_party/move/move-compiler-v2/tests/v1.matched index a3bcb45fd0fbb..0bf656240f39c 100644 --- a/third_party/move/move-compiler-v2/tests/v1.matched +++ b/third_party/move/move-compiler-v2/tests/v1.matched @@ -68,6 +68,14 @@ move-compiler/tests/move_check/borrows/return_borrowed_local_invalid.exp move- move-compiler/tests/move_check/borrows/return_mutual_borrows.exp move-compiler-v2/tests/reference-safety/v1-tests/return_mutual_borrows.exp move-compiler/tests/move_check/borrows/return_mutual_borrows_invalid.exp move-compiler-v2/tests/reference-safety/v1-tests/return_mutual_borrows_invalid.exp move-compiler/tests/move_check/borrows/unused_ref.exp move-compiler-v2/tests/reference-safety/v1-tests/unused_ref.exp +move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard1.exp move-compiler-v2/tests/bytecode-generator/wildcard1.exp +move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard2.exp move-compiler-v2/tests/bytecode-generator/wildcard2.exp +move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard3.exp move-compiler-v2/tests/bytecode-generator/wildcard3.exp +move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard4.exp move-compiler-v2/tests/bytecode-generator/wildcard4.exp +move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard5.exp move-compiler-v2/tests/bytecode-generator/wildcard5.exp +move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard6.exp move-compiler-v2/tests/bytecode-generator/wildcard6.exp +move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard7.exp move-compiler-v2/tests/bytecode-generator/wildcard7.exp +move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard8.exp move-compiler-v2/tests/bytecode-generator/wildcard8.exp move-compiler/tests/move_check/translated_ir_tests/move/commands/assign_in_one_if_branch.exp move-compiler-v2/tests/uninit-use-checker/v1-commands/assign_in_one_if_branch.exp move-compiler/tests/move_check/translated_ir_tests/move/commands/assign_wrong_if_branch.exp move-compiler-v2/tests/uninit-use-checker/v1-commands/assign_wrong_if_branch.exp move-compiler/tests/move_check/translated_ir_tests/move/commands/assign_wrong_if_branch_no_else.exp move-compiler-v2/tests/uninit-use-checker/v1-commands/assign_wrong_if_branch_no_else.exp diff --git a/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard1.exp b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard1.exp new file mode 100644 index 0000000000000..65b387d6e08a2 --- /dev/null +++ b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard1.exp @@ -0,0 +1,9 @@ +error[E04005]: expected a single type + ┌─ tests/move_check/v2_tests/bytecode-generator/wildcard1.move:7:13 + │ +2 │ fun tup(): (u64, u64) { + │ ---------- Expected a single type, but found expression list type: '(u64, u64)' + · +7 │ let _ = tup(); + │ ^ Invalid type for local + diff --git a/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard1.move b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard1.move new file mode 100644 index 0000000000000..4434885e2308b --- /dev/null +++ b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard1.move @@ -0,0 +1,9 @@ +module 0xc0ffee::m { + fun tup(): (u64, u64) { + (0, 0) + } + + public fun bar() { + let _ = tup(); + } +} diff --git a/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard2.exp b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard2.exp new file mode 100644 index 0000000000000..1d1e8f5fe24be --- /dev/null +++ b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard2.exp @@ -0,0 +1,8 @@ +error[E06002]: use of unassigned variable + ┌─ tests/move_check/v2_tests/bytecode-generator/wildcard2.move:4:17 + │ +3 │ let x: u64; + │ - The variable 'x' does not have a value. The variable must be assigned a value before being used. +4 │ let _ = x; + │ ^ Invalid usage of unassigned variable 'x' + diff --git a/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard2.move b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard2.move new file mode 100644 index 0000000000000..9e4e973875ffd --- /dev/null +++ b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard2.move @@ -0,0 +1,6 @@ +module 0xc0ffee::m { + public fun baz() { + let x: u64; + let _ = x; + } +} diff --git a/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard3.exp b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard3.exp new file mode 100644 index 0000000000000..dcc91c7a1e37c --- /dev/null +++ b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard3.exp @@ -0,0 +1,22 @@ +error[E05001]: ability constraint not satisfied + ┌─ tests/move_check/v2_tests/bytecode-generator/wildcard3.move:5:13 + │ +2 │ struct S {} + │ - To satisfy the constraint, the 'drop' ability would need to be added here +3 │ +4 │ public fun foo(s: S) { + │ - The type '0xC0FFEE::m::S' does not have the ability 'drop' +5 │ let _ = s; + │ ^ Cannot ignore values without the 'drop' ability. The value must be used + +error[E05001]: ability constraint not satisfied + ┌─ tests/move_check/v2_tests/bytecode-generator/wildcard3.move:10:13 + │ + 2 │ struct S {} + │ - To satisfy the constraint, the 'drop' ability would need to be added here + · + 9 │ let s = S{}; + │ --- The type '0xC0FFEE::m::S' does not have the ability 'drop' +10 │ let _ = s; + │ ^ Cannot ignore values without the 'drop' ability. The value must be used + diff --git a/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard3.move b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard3.move new file mode 100644 index 0000000000000..098ed212f9f74 --- /dev/null +++ b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard3.move @@ -0,0 +1,12 @@ +module 0xc0ffee::m { + struct S {} + + public fun foo(s: S) { + let _ = s; + } + + public fun bar() { + let s = S{}; + let _ = s; + } +} diff --git a/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard4.exp b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard4.exp new file mode 100644 index 0000000000000..1056ac05de95b --- /dev/null +++ b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard4.exp @@ -0,0 +1,9 @@ +error[E07002]: mutable ownership violated + ┌─ tests/move_check/v2_tests/bytecode-generator/wildcard4.move:6:17 + │ +4 │ let r = &mut x; + │ ------ It is still being mutably borrowed by this reference +5 │ let y = &mut x; +6 │ let _ = freeze(y); + │ ^^^^^^^^^ Invalid freeze. + diff --git a/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard4.move b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard4.move new file mode 100644 index 0000000000000..4b84b1e270f93 --- /dev/null +++ b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard4.move @@ -0,0 +1,9 @@ +module 0xc0ffee::m { + fun test() { + let x = 3; + let r = &mut x; + let y = &mut x; + let _ = freeze(y); + *r = 4; + } +} diff --git a/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard5.move b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard5.move new file mode 100644 index 0000000000000..b322385c1a16c --- /dev/null +++ b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard5.move @@ -0,0 +1,11 @@ +module 0xc0ffee::m { + struct S { + x: u64, + y: u64 + } + + public fun test() { + let s = S {x: 3, y: 4}; + let S {x: _, y: _} = s; + } +} diff --git a/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard6.exp b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard6.exp new file mode 100644 index 0000000000000..84a92d79c5be6 --- /dev/null +++ b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard6.exp @@ -0,0 +1,9 @@ +error[E06002]: use of unassigned variable + ┌─ tests/move_check/v2_tests/bytecode-generator/wildcard6.move:4:31 + │ +4 │ let (y, _) = (move x, x); + │ ------ ^ Invalid usage of previously moved variable 'x'. + │ │ + │ The value of 'x' was previously moved here. + │ Suggestion: use 'copy x' to avoid the move. + diff --git a/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard6.move b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard6.move new file mode 100644 index 0000000000000..99334951cf2bf --- /dev/null +++ b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard6.move @@ -0,0 +1,7 @@ +module 0xc0ffee::m { + public fun test2(): u64 { + let x = 40; + let (y, _) = (move x, x); + y + } +} diff --git a/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard7.exp b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard7.exp new file mode 100644 index 0000000000000..df5a3bb654a69 --- /dev/null +++ b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard7.exp @@ -0,0 +1,17 @@ +warning[W09003]: unused assignment + ┌─ tests/move_check/v2_tests/bytecode-generator/wildcard7.move:6:17 + │ +6 │ let (_, q) = (x, z); + │ ^ Unused assignment or binding for local 'q'. Consider removing, replacing with '_', or prefixing with '_' (e.g., '_q') + +error[E06002]: use of unassigned variable + ┌─ tests/move_check/v2_tests/bytecode-generator/wildcard7.move:6:23 + │ +5 │ let y = move x; + │ ------ + │ │ + │ The value of 'x' was previously moved here. + │ Suggestion: use 'copy x' to avoid the move. +6 │ let (_, q) = (x, z); + │ ^ Invalid usage of previously moved variable 'x'. + diff --git a/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard7.move b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard7.move new file mode 100644 index 0000000000000..9cc04703832cf --- /dev/null +++ b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard7.move @@ -0,0 +1,9 @@ +module 0xc0ffee::m { + public fun test(): u8 { + let x = 40; + let z = 30; + let y = move x; + let (_, q) = (x, z); + y + } +} diff --git a/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard8.exp b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard8.exp new file mode 100644 index 0000000000000..063bdf8fcf70d --- /dev/null +++ b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard8.exp @@ -0,0 +1,16 @@ +error[E06002]: use of unassigned variable + ┌─ tests/move_check/v2_tests/bytecode-generator/wildcard8.move:4:23 + │ +3 │ let x: u64; + │ - The variable 'x' does not have a value. The variable must be assigned a value before being used. +4 │ let (_, _) = (x, x); + │ ^ Invalid usage of unassigned variable 'x' + +error[E06002]: use of unassigned variable + ┌─ tests/move_check/v2_tests/bytecode-generator/wildcard8.move:4:26 + │ +3 │ let x: u64; + │ - The variable 'x' does not have a value. The variable must be assigned a value before being used. +4 │ let (_, _) = (x, x); + │ ^ Invalid usage of unassigned variable 'x' + diff --git a/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard8.move b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard8.move new file mode 100644 index 0000000000000..548be15785bc6 --- /dev/null +++ b/third_party/move/move-compiler/tests/move_check/v2_tests/bytecode-generator/wildcard8.move @@ -0,0 +1,6 @@ +module 0xc0ffee::m { + public fun test() { + let x: u64; + let (_, _) = (x, x); + } +} From 4fa81cccb12a15b1bf9d2479ff767a6a1deb7ec5 Mon Sep 17 00:00:00 2001 From: Vineeth Kashyap Date: Fri, 12 Apr 2024 16:11:17 -0400 Subject: [PATCH 8/8] Update prover baseline --- .../sources/functional/data_invariant_for_mut_ref_arg.v2_exp | 1 + 1 file changed, 1 insertion(+) diff --git a/third_party/move/move-prover/tests/sources/functional/data_invariant_for_mut_ref_arg.v2_exp b/third_party/move/move-prover/tests/sources/functional/data_invariant_for_mut_ref_arg.v2_exp index 9ec50a0112d4e..f56c9d68d1551 100644 --- a/third_party/move/move-prover/tests/sources/functional/data_invariant_for_mut_ref_arg.v2_exp +++ b/third_party/move/move-prover/tests/sources/functional/data_invariant_for_mut_ref_arg.v2_exp @@ -27,6 +27,7 @@ error: data invariant does not hold = s = = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:27: push_2 = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:28: push_2 + = s = = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:22: push_2 = s = = at tests/sources/functional/data_invariant_for_mut_ref_arg.move:8