mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-11-01 00:19:52 +00:00
Provide unique name from closures with same name (#488)
In YUL it's possible to declare closure with a same name, but in different scope, which previously resulted to func name conflict during LLVM IR construction. To solve this, track YUL scope when building LLVM IR and a special counter that increments every time function with the same name exists in LLVM module. There's still assert if somehow within the same scope there 2 functions with the same name, which should be forbidden by Yul Fixes: #474 --------- Co-authored-by: LJ <81748770+elle-j@users.noreply.github.com>
This commit is contained in:
1 parent
dc155efc73
commit
61ac247135
8 files changed
+218
-19
No files matched your search
@@ -2,7 +2,9 @@
|
||||
|
||||
use crate::cli_utils::{
|
||||
assert_command_failure, assert_command_success, assert_equal_exit_codes, execute_resolc,
|
||||
execute_solc, RESOLC_YUL_FLAG, SOLC_YUL_FLAG, YUL_CONTRACT_PATH, YUL_INVALID_HEX_NIBBLES_PATH,
|
||||
execute_solc, RESOLC_YUL_FLAG, SOLC_YUL_FLAG, YUL_CONTRACT_PATH,
|
||||
YUL_DUPLICATE_FUNCTIONS_DEEP_NESTING_PATH, YUL_DUPLICATE_FUNCTIONS_SWITCH_PATH,
|
||||
YUL_INVALID_HEX_NIBBLES_PATH,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -35,3 +37,29 @@ fn bails_with_invalid_input_file() {
|
||||
let solc_result = execute_solc(&[YUL_INVALID_HEX_NIBBLES_PATH, SOLC_YUL_FLAG]);
|
||||
assert_equal_exit_codes(&solc_result, &resolc_result);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn duplicate_functions_in_switch_cases() {
|
||||
let resolc_result = execute_resolc(&[
|
||||
YUL_DUPLICATE_FUNCTIONS_SWITCH_PATH,
|
||||
RESOLC_YUL_FLAG,
|
||||
"--bin",
|
||||
]);
|
||||
assert_command_success(
|
||||
&resolc_result,
|
||||
"Duplicate function names in different switch cases",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn duplicate_functions_deep_nesting() {
|
||||
let resolc_result = execute_resolc(&[
|
||||
YUL_DUPLICATE_FUNCTIONS_DEEP_NESTING_PATH,
|
||||
RESOLC_YUL_FLAG,
|
||||
"--bin",
|
||||
]);
|
||||
assert_command_success(
|
||||
&resolc_result,
|
||||
"Duplicate function names in deeply nested switch cases",
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user