File tree Expand file tree Collapse file tree 5 files changed +165
-0
lines changed
test/libyul/controlFlowSideEffects Expand file tree Collapse file tree 5 files changed +165
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ function a () -> x {
3+ revert (0 , 0 )
4+ }
5+ function b () -> x {
6+ return (0 , 0 )
7+ }
8+ function c () {
9+ sstore (a (), b ())
10+ }
11+ function d () {
12+ sstore (b (), a ())
13+ }
14+ }
15+ // ----
16+ // a: can revert
17+ // b: can terminate
18+ // c: can terminate
19+ // d: can revert
Original file line number Diff line number Diff line change 1+ {
2+ function a () {
3+ for { leave } calldataload (0 ) { } {
4+ break
5+ revert (0 , 0 )
6+ }
7+ }
8+ function b () {
9+ for { } calldataload (0 ) { leave } {
10+ break
11+ revert (0 , 0 )
12+ }
13+ }
14+ function b2 () {
15+ for { } calldataload (0 ) { leave } {
16+ revert (0 , 0 )
17+ }
18+ }
19+ function c () {
20+ for { } calldataload (0 ) { revert (0 , 0 ) } {
21+ break
22+ }
23+ }
24+ function c2 () {
25+ for { } calldataload (0 ) { revert (0 , 0 ) } {
26+ break
27+ revert (0 , 0 )
28+ }
29+ }
30+ function d () {
31+ for { } calldataload (0 ) { revert (0 , 0 ) } {
32+ continue
33+ }
34+ }
35+ function e () {
36+ for { } calldataload (0 ) { revert (0 , 0 ) } {
37+ if calldataload (1 ) { break }
38+ }
39+ }
40+ function f () {
41+ for { } calldataload (0 ) { } {
42+ if calldataload (1 ) { continue }
43+ revert (0 , 0 )
44+ }
45+ }
46+ }
47+ // ----
48+ // a: can continue
49+ // b: can continue
50+ // b2: can revert, can continue
51+ // c: can continue
52+ // c2: can continue
53+ // d: can revert, can continue
54+ // e: can revert, can continue
55+ // f: can revert, can continue
Original file line number Diff line number Diff line change 1+ {
2+ function a () {
3+ revert (0 , 0 )
4+ leave
5+ }
6+ function b () {
7+ leave
8+ revert (0 , 0 )
9+ }
10+ }
11+ // ----
12+ // a: can revert
13+ // b: can continue
Original file line number Diff line number Diff line change 1+ {
2+ function a () {
3+ if calldataload (0 ) {
4+ revert (0 , 0 )
5+ }
6+ reg ()
7+ b ()
8+ }
9+ function b () {
10+ a ()
11+ return (0 , 0 )
12+ }
13+ function c () {
14+ c ()
15+ revert (0 , 0 )
16+ }
17+ function d () {
18+ switch calldataload (0 )
19+ case 0 { x () }
20+ case 1 { y () reg () revert (0 , 0 ) }
21+ default { z () }
22+ }
23+ function x () { d () revert (0 , 0 ) }
24+ function y () { reg () x () }
25+ function z () { y () }
26+
27+ function reg () {}
28+ }
29+ // ----
30+ // a: can revert
31+ // b: can revert
32+ // c
33+ // d
34+ // reg: can continue
35+ // x
36+ // y
37+ // z
Original file line number Diff line number Diff line change 1+ {
2+ function a () {
3+ switch calldataload (0 )
4+ case 0 { revert (0 , 0 ) }
5+ }
6+ function b () {
7+ switch calldataload (0 )
8+ case 0 { revert (0 , 0 ) }
9+ default { revert (0 , 0 ) }
10+ }
11+ function c () {
12+ return (0 , 0 )
13+ switch calldataload (0 )
14+ case 0 { revert (0 , 0 ) }
15+ default { }
16+ }
17+ function d () {
18+ switch calldataload (0 )
19+ case 0 { return (0 , 0 ) }
20+ default { return (0 , 0 ) }
21+ revert (0 , 0 )
22+ }
23+ function e () {
24+ switch calldataload (0 )
25+ case 0 { return (0 , 0 ) }
26+ revert (0 , 0 )
27+ }
28+ function f () {
29+ switch calldataload (0 )
30+ case 0 { leave }
31+ default { leave }
32+ revert (0 , 0 )
33+ }
34+ }
35+ // ----
36+ // a: can revert, can continue
37+ // b: can revert
38+ // c: can terminate
39+ // d: can terminate
40+ // e: can terminate, can revert
41+ // f: can continue
You can’t perform that action at this time.
0 commit comments