-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathyul_function_scoping.rs
More file actions
43 lines (40 loc) · 1.08 KB
/
yul_function_scoping.rs
File metadata and controls
43 lines (40 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! Tests for Yul function scoping and duplicate function name handling.
use crate::test_utils::build_yul;
/// Reproducer from GH-474: duplicate `f` across switch cases.
#[test]
fn duplicate_function_names_in_switch_cases() {
let code = r#"
object "Test" {
code {
{
let size := datasize("Test_deployed")
codecopy(0, dataoffset("Test_deployed"), size)
return(0, size)
}
}
object "Test_deployed" {
code {
{
switch calldataload(0)
case 0 {
function f() -> ret {
ret := 1
}
mstore(0, f())
return(0, 32)
}
case 1 {
function f() -> ret {
ret := 2
}
mstore(0, f())
return(0, 32)
}
}
}
}
}
"#;
build_yul(&[("test.yul", code)])
.expect("should compile duplicate function names in switch cases");
}