mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-10-20 18:56:17 +00:00
Fix Yul mode discarding solc validation errors (#478)
In `--yul` mode, resolc now properly exits when solc reports validation errors (e.g., invalid hex literals, variable redeclarations), matching `--standard-json behavior.` `runs_without_input_file` was adapted because it was relying on it where the new behavior correctly matches solc --strict-assembly. Closes #477 Co-authored-by: minimax-m2.5 <neo@zion> --------- Signed-off-by: xermicus <bigcyrill@hotmail.com>
This commit is contained in:
1 parent
0cd949aa66
commit
d8d998c114
5 files changed
+40
-12
No files matched your search
@@ -22,6 +22,8 @@ pub const YUL_CONTRACT_PATH: &str = "src/tests/data/yul/contract.yul";
|
||||
pub const YUL_MEMSET_CONTRACT_PATH: &str = "src/tests/data/yul/memset.yul";
|
||||
/// The return YUL contract test fixture path.
|
||||
pub const YUL_RETURN_CONTRACT_PATH: &str = "src/tests/data/yul/return.yul";
|
||||
/// The invalid YUL contract test fixture path (hex literal with odd number of nibbles).
|
||||
pub const YUL_INVALID_HEX_NIBBLES_PATH: &str = "src/tests/data/yul/invalid_hex_nibbles.yul";
|
||||
|
||||
/// The standard JSON contracts test fixture path.
|
||||
pub const STANDARD_JSON_CONTRACTS_PATH: &str =
|
||||
|
||||
@@ -84,7 +84,8 @@ pub fn yul<T: Compiler>(
|
||||
memory_config: SolcStandardJsonInputSettingsPolkaVMMemory,
|
||||
) -> anyhow::Result<Build> {
|
||||
let libraries = SolcStandardJsonInputSettingsLibraries::try_from(libraries)?;
|
||||
solc.validate_yul_paths(input_files, libraries.clone(), messages)?;
|
||||
let solc_output = solc.validate_yul_paths(input_files, libraries.clone(), messages)?;
|
||||
solc_output.exit_on_error();
|
||||
|
||||
let linker_symbols = libraries.as_linker_symbols()?;
|
||||
let project = Project::try_from_yul_paths(input_files, None, libraries, &debug_config)?;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! The tests for running resolc with yul option.
|
||||
|
||||
use crate::cli_utils::{
|
||||
assert_command_success, assert_equal_exit_codes, execute_resolc, execute_solc, RESOLC_YUL_FLAG,
|
||||
SOLC_YUL_FLAG, YUL_CONTRACT_PATH,
|
||||
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,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -18,15 +18,20 @@ fn runs_with_valid_input_file() {
|
||||
assert_equal_exit_codes(&solc_result, &resolc_result);
|
||||
}
|
||||
|
||||
/// While the `solc` Solidity mode requires output selection,
|
||||
/// the strict-assembly mode does not.
|
||||
///
|
||||
/// `resolc` exhibits consistent behavior for both modes.
|
||||
#[test]
|
||||
fn runs_without_input_file() {
|
||||
fn fails_without_input_file() {
|
||||
let resolc_result = execute_resolc(&[RESOLC_YUL_FLAG]);
|
||||
assert_command_success(&resolc_result, "Omitting an input file");
|
||||
assert!(resolc_result
|
||||
.stderr
|
||||
.contains("Compiler run successful. No output requested"));
|
||||
assert_command_failure(&resolc_result, "Omitting an input file");
|
||||
|
||||
let solc_result = execute_solc(&[SOLC_YUL_FLAG]);
|
||||
assert_equal_exit_codes(&solc_result, &resolc_result);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bails_with_invalid_input_file() {
|
||||
let resolc_result = execute_resolc(&[YUL_INVALID_HEX_NIBBLES_PATH, RESOLC_YUL_FLAG]);
|
||||
assert_command_failure(&resolc_result, "Providing an invalid input file");
|
||||
|
||||
let solc_result = execute_solc(&[YUL_INVALID_HEX_NIBBLES_PATH, SOLC_YUL_FLAG]);
|
||||
assert_equal_exit_codes(&solc_result, &resolc_result);
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
object "Test" {
|
||||
code {
|
||||
{
|
||||
let size := datasize("Test_deployed")
|
||||
codecopy(0, dataoffset("Test_deployed"), size)
|
||||
return(0, size)
|
||||
}
|
||||
}
|
||||
object "Test_deployed" {
|
||||
code {
|
||||
{
|
||||
// Invalid: hex literal with odd number of nibbles.
|
||||
let x := hex"abc"
|
||||
mstore(0, x)
|
||||
return(0, 32)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user