-
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.
Merge branch 'main' into vk/mutation-skip
- Loading branch information
Showing
30 changed files
with
503 additions
and
62 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
78 changes: 78 additions & 0 deletions
78
third_party/move/move-compiler-v2/tests/bytecode-generator/loop_labels.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,78 @@ | ||
// -- Model dump before bytecode pipeline | ||
module 0x815::test { | ||
private fun f1() { | ||
loop { | ||
loop { | ||
loop { | ||
if true { | ||
loop { | ||
if false { | ||
continue[3] | ||
} else { | ||
break[1] | ||
}; | ||
break | ||
} | ||
} else { | ||
continue[2] | ||
} | ||
} | ||
}; | ||
break | ||
} | ||
} | ||
} // end 0x815::test | ||
|
||
// -- Sourcified model before bytecode pipeline | ||
module 0x815::test { | ||
fun f1() { | ||
'l0: loop { | ||
loop 'l1: loop if (true) loop { | ||
if (false) continue 'l0 else break 'l1; | ||
break | ||
} else continue 'l0; | ||
break | ||
} | ||
} | ||
} | ||
|
||
============ initial bytecode ================ | ||
|
||
[variant baseline] | ||
fun test::f1() { | ||
var $t0: bool | ||
var $t1: bool | ||
0: label L0 | ||
1: label L2 | ||
2: label L4 | ||
3: $t0 := true | ||
4: if ($t0) goto 5 else goto 19 | ||
5: label L6 | ||
6: label L9 | ||
7: $t1 := false | ||
8: if ($t1) goto 9 else goto 12 | ||
9: label L11 | ||
10: goto 0 | ||
11: goto 14 | ||
12: label L12 | ||
13: goto 23 | ||
14: label L13 | ||
15: goto 17 | ||
16: goto 6 | ||
17: label L10 | ||
18: goto 21 | ||
19: label L7 | ||
20: goto 0 | ||
21: label L8 | ||
22: goto 2 | ||
23: label L5 | ||
24: goto 1 | ||
25: label L3 | ||
26: goto 28 | ||
27: goto 0 | ||
28: label L1 | ||
29: return () | ||
} | ||
|
||
|
||
============ bytecode verification succeeded ======== |
14 changes: 14 additions & 0 deletions
14
third_party/move/move-compiler-v2/tests/bytecode-generator/loop_labels.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,14 @@ | ||
module 0x815::test { | ||
fun f1() { | ||
'outer: loop { | ||
// unlabeled loop, but counts in nesting in AST | ||
loop { | ||
'inner: loop if (true) loop { | ||
if (false) continue 'outer else break 'inner; | ||
break | ||
} else continue 'outer | ||
}; | ||
break | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
third_party/move/move-compiler-v2/tests/checking-lang-v1/loop_labels.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,31 @@ | ||
|
||
Diagnostics: | ||
error: unsupported language construct | ||
┌─ tests/checking-lang-v1/loop_labels.move:3:9 | ||
│ | ||
3 │ 'outer: loop { | ||
│ ^^^^^^ loop labels are not enabled before version 2.1 | ||
|
||
error: unsupported language construct | ||
┌─ tests/checking-lang-v1/loop_labels.move:6:17 | ||
│ | ||
6 │ 'inner: loop if (true) loop { | ||
│ ^^^^^^ loop labels are not enabled before version 2.1 | ||
|
||
error: unsupported language construct | ||
┌─ tests/checking-lang-v1/loop_labels.move:7:41 | ||
│ | ||
7 │ if (false) continue 'outer else break 'inner; | ||
│ ^^^^^^ loop labels are not enabled before version 2.1 | ||
|
||
error: unsupported language construct | ||
┌─ tests/checking-lang-v1/loop_labels.move:7:59 | ||
│ | ||
7 │ if (false) continue 'outer else break 'inner; | ||
│ ^^^^^^ loop labels are not enabled before version 2.1 | ||
|
||
error: unsupported language construct | ||
┌─ tests/checking-lang-v1/loop_labels.move:9:33 | ||
│ | ||
9 │ } else continue 'outer | ||
│ ^^^^^^ loop labels are not enabled before version 2.1 |
14 changes: 14 additions & 0 deletions
14
third_party/move/move-compiler-v2/tests/checking-lang-v1/loop_labels.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,14 @@ | ||
module 0x815::test { | ||
fun f1() { | ||
'outer: loop { | ||
// unlabeled loop, but counts in nesting in AST | ||
loop { | ||
'inner: loop if (true) loop { | ||
if (false) continue 'outer else break 'inner; | ||
break | ||
} else continue 'outer | ||
}; | ||
break | ||
} | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
third_party/move/move-compiler-v2/tests/checking/control_flow/loop_labels_check_err.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,21 @@ | ||
|
||
Diagnostics: | ||
error: label `'outer` undefined | ||
┌─ tests/checking/control_flow/loop_labels_check_err.move:3:15 | ||
│ | ||
3 │ break 'outer; | ||
│ ^^^^^^ | ||
|
||
error: label `'inner` undefined | ||
┌─ tests/checking/control_flow/loop_labels_check_err.move:5:19 | ||
│ | ||
5 │ break 'inner | ||
│ ^^^^^^ | ||
|
||
error: label `'l1` already used by outer loop | ||
┌─ tests/checking/control_flow/loop_labels_check_err.move:11:19 | ||
│ | ||
11 │ 'l1: loop 'l1: loop {}; | ||
│ --- ^^^ | ||
│ │ | ||
│ outer definition of label |
14 changes: 14 additions & 0 deletions
14
third_party/move/move-compiler-v2/tests/checking/control_flow/loop_labels_check_err.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,14 @@ | ||
module 0x815::test { | ||
fun undefined_label() { | ||
break 'outer; | ||
'outer: loop { | ||
break 'inner | ||
} | ||
} | ||
|
||
fun duplicate_label() { | ||
'l1: loop {}; | ||
'l1: loop 'l1: loop {}; | ||
'l1: loop {} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
third_party/move/move-compiler-v2/tests/checking/control_flow/loop_labels_check_ok.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,37 @@ | ||
// -- Model dump before bytecode pipeline | ||
module 0x815::test { | ||
private fun f1() { | ||
loop { | ||
loop { | ||
loop { | ||
if true { | ||
loop { | ||
if false { | ||
continue[3] | ||
} else { | ||
break[1] | ||
}; | ||
break | ||
} | ||
} else { | ||
continue[2] | ||
} | ||
} | ||
}; | ||
break | ||
} | ||
} | ||
} // end 0x815::test | ||
|
||
// -- Sourcified model before bytecode pipeline | ||
module 0x815::test { | ||
fun f1() { | ||
'l0: loop { | ||
loop 'l1: loop if (true) loop { | ||
if (false) continue 'l0 else break 'l1; | ||
break | ||
} else continue 'l0; | ||
break | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
third_party/move/move-compiler-v2/tests/checking/control_flow/loop_labels_check_ok.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,14 @@ | ||
module 0x815::test { | ||
fun f1() { | ||
'outer: loop { | ||
// unlabeled loop, but counts in nesting in AST | ||
loop { | ||
'inner: loop if (true) loop { | ||
if (false) continue 'outer else break 'inner; | ||
break | ||
} else continue 'outer | ||
}; | ||
break | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
third_party/move/move-compiler-v2/tests/checking/control_flow/loop_labels_parse_err1.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,10 @@ | ||
|
||
Diagnostics: | ||
error: unexpected token | ||
┌─ tests/checking/control_flow/loop_labels_parse_err1.move:3:13 | ||
│ | ||
3 │ 'a: if (true) false else true | ||
│ ^^ | ||
│ │ | ||
│ Unexpected 'if' | ||
│ Expected one of: `while` or `loop` |
5 changes: 5 additions & 0 deletions
5
third_party/move/move-compiler-v2/tests/checking/control_flow/loop_labels_parse_err1.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,5 @@ | ||
module 0x815::test { | ||
fun f1(): bool { | ||
'a: if (true) false else true | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
third_party/move/move-compiler-v2/tests/checking/control_flow/loop_labels_parse_err2.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,10 @@ | ||
|
||
Diagnostics: | ||
error: unexpected token | ||
┌─ tests/checking/control_flow/loop_labels_parse_err2.move:3:13 | ||
│ | ||
3 │ 'a: if (true) false else true | ||
│ ^^ | ||
│ │ | ||
│ Unexpected 'if' | ||
│ Expected one of: `while` or `loop` |
5 changes: 5 additions & 0 deletions
5
third_party/move/move-compiler-v2/tests/checking/control_flow/loop_labels_parse_err2.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,5 @@ | ||
module 0x815::test { | ||
fun f1(): bool { | ||
'a: if (true) false else true | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
third_party/move/move-compiler-v2/tests/checking/control_flow/loop_labels_parse_err3.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,7 @@ | ||
|
||
Diagnostics: | ||
error: invalid character | ||
┌─ tests/checking/control_flow/loop_labels_parse_err3.move:3:10 | ||
│ | ||
3 │ ': if (true) false else true | ||
│ ^ Label quote must be followed by 'A-Z', `a-z', or '_' |
9 changes: 9 additions & 0 deletions
9
third_party/move/move-compiler-v2/tests/checking/control_flow/loop_labels_parse_err3.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,9 @@ | ||
module 0x815::test { | ||
fun f1(): bool { | ||
': if (true) false else true | ||
} | ||
|
||
fun f1(): bool { | ||
'0x: if (true) false else true | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
third_party/move/move-compiler-v2/tests/checking/control_flow/loop_labels_parse_err4.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,7 @@ | ||
|
||
Diagnostics: | ||
error: invalid character | ||
┌─ tests/checking/control_flow/loop_labels_parse_err4.move:3:10 | ||
│ | ||
3 │ '0x: if (true) false else true | ||
│ ^ Label quote must be followed by 'A-Z', `a-z', or '_' |
5 changes: 5 additions & 0 deletions
5
third_party/move/move-compiler-v2/tests/checking/control_flow/loop_labels_parse_err4.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,5 @@ | ||
module 0x815::test { | ||
fun f1(): bool { | ||
'0x: if (true) false else true | ||
} | ||
} |
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
1 change: 1 addition & 0 deletions
1
third_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/loop_labels.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 @@ | ||
processed 1 task |
18 changes: 18 additions & 0 deletions
18
...d_party/move/move-compiler-v2/transactional-tests/tests/no-v1-comparison/loop_labels.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,18 @@ | ||
//# run | ||
script { | ||
fun main() { | ||
let result = 0; | ||
'outer: while (result < 100) { | ||
while (result < 50) { | ||
'inner: while (result < 30) { | ||
result += 1; | ||
continue 'outer | ||
}; | ||
result += 10; | ||
continue 'outer | ||
}; | ||
result += 20 | ||
}; | ||
assert!(result == 110); | ||
} | ||
} |
Oops, something went wrong.