forked from MystenLabs/sui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[move-2024] Fix issue with namd block cfg lowering (MystenLabs#15791)
## Description This fixes a bug for named blocks. ## Test Plan New tests that work --- If your changes are not user-facing and do not break anything, you can skip the following section. Otherwise, please briefly describe what has changed under the Release Notes section. ### Type of Change (Check all that apply) - [ ] protocol change - [ ] user-visible impact - [ ] breaking change for a client SDKs - [ ] breaking change for FNs (FN binary must upgrade) - [ ] breaking change for validators or node operators (must upgrade binaries) - [ ] breaking change for on-chain data layout - [ ] necessitate either a data wipe or data migration ### Release notes
- Loading branch information
Showing
6 changed files
with
190 additions
and
2 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
.../move/crates/move-compiler-transactional-tests/tests/control_flow/unused_named_blocks.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 3 tasks |
100 changes: 100 additions & 0 deletions
100
...move/crates/move-compiler-transactional-tests/tests/control_flow/unused_named_blocks.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,100 @@ | ||
//# init --edition 2024.alpha | ||
|
||
//# publish | ||
module 0x42::m { | ||
|
||
public fun t0(): u64 { | ||
if ('block: { true }) { | ||
10 | ||
} else { | ||
20 | ||
} | ||
} | ||
|
||
public fun t1(): u64 { | ||
if ('block: { true }) { | ||
'block: { 10 } | ||
} else { | ||
20 | ||
} | ||
} | ||
|
||
public fun t2(): u64 { | ||
if ('block: { false }) { | ||
20 | ||
} else { | ||
'block: { 10 } | ||
} | ||
} | ||
|
||
public fun t3(): u64 { | ||
if ('block: { false }) { | ||
20 | ||
} else { | ||
while (false) { 'block: { 20 }; }; | ||
'block: { 10 } | ||
} | ||
} | ||
|
||
public fun t4(): u64 { | ||
let mut count = 0; | ||
let mut x = 0; | ||
while (x < 10) { | ||
'inner: { | ||
count = count + 1; | ||
}; | ||
x = x + 1; | ||
}; | ||
count | ||
} | ||
|
||
public fun t5(): u64 { | ||
let mut count = 0; | ||
let (start, stop) = (0, 10); | ||
let mut i = start; | ||
while (i < stop) { | ||
let x = i; | ||
count = count + x * x; | ||
i = i + 1; | ||
}; | ||
count | ||
} | ||
|
||
public fun t6(): u64 { | ||
let mut count = 0u64; | ||
{ | ||
let (start, stop) = (0, 10); | ||
'macro: { | ||
'lambdabreak: { | ||
{ | ||
let mut i = start; | ||
while (i < stop) 'loop: { | ||
{ | ||
let x = i; | ||
'lambdareturn: { | ||
count = count + x * x; | ||
} | ||
}; | ||
i = i + 1; | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
count | ||
} | ||
} | ||
|
||
//# run | ||
module 0x42::main { | ||
use 0x42::m; | ||
fun main() { | ||
assert!(m::t0() == 10, 0); | ||
assert!(m::t1() == 10, 1); | ||
assert!(m::t2() == 10, 2); | ||
assert!(m::t3() == 10, 3); | ||
assert!(m::t4() == 10, 4); | ||
assert!(m::t5() == 285, 5); | ||
assert!(m::t6() == 285, 6); | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
external-crates/move/crates/move-compiler/tests/move_2024/cfgir/loops.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,38 @@ | ||
|
||
module 0x42::m { | ||
fun t0() { | ||
let mut count = 0; | ||
let (start, stop) = (0, 10); | ||
let mut i = start; | ||
while (i < stop) { | ||
let x = i; | ||
count = count + x * x; | ||
i = i + 1; | ||
}; | ||
assert!(count == 285, 0); | ||
} | ||
|
||
fun t1() { | ||
let mut count = 0u64; | ||
{ | ||
let (start, stop) = (0, 10); | ||
'macro: { | ||
'lambdabreak: { | ||
{ | ||
let mut i = start; | ||
while (i < stop) 'loop: { | ||
{ | ||
let x = i; | ||
'lambdareturn: { | ||
count = count + x * x; | ||
} | ||
}; | ||
i = i + 1; | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
assert!(count == 285, 0); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
external-crates/move/crates/move-compiler/tests/move_2024/cfgir/named_blocks.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,48 @@ | ||
module 0x42::a { | ||
|
||
fun t0(): u64 { | ||
if ('block: { true }) { | ||
10 | ||
} else { | ||
20 | ||
} | ||
} | ||
|
||
fun t1(): u64 { | ||
if ('block: { true }) { | ||
'block: { 10 } | ||
} else { | ||
20 | ||
} | ||
} | ||
|
||
fun t2(): u64 { | ||
if ('block: { false }) { | ||
20 | ||
} else { | ||
'block: { 10 } | ||
} | ||
} | ||
|
||
fun t3(): u64 { | ||
if ('block: { false }) { | ||
20 | ||
} else { | ||
while (false) { 'block: { 20 }; }; | ||
'block: { 10 } | ||
} | ||
} | ||
|
||
fun t4(): u64 { | ||
let mut count = 0; | ||
let mut x = 0; | ||
while (x < 10) { | ||
'inner: { | ||
count = count + 1; | ||
}; | ||
x = x + 1; | ||
}; | ||
count | ||
} | ||
|
||
} |