Skip to content

Commit 525b4c7

Browse files
authored
Merge pull request #11853 from Midhun07/develop
Disallow `--experimental-via-ir` in Standard JSON, assembler and linker modes
2 parents d1a7921 + 11065c6 commit 525b4c7

File tree

3 files changed

+37
-2
lines changed

3 files changed

+37
-2
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Compiler Features:
88
* Immutable variables can be read at construction time once they are initialized.
99
* SMTChecker: Support low level ``call`` as external calls to unknown code.
1010
* SMTChecker: Add constraints to better correlate ``address(this).balance`` and ``msg.value``.
11+
* Commandline Interface: Disallowed the ``--experimental-via-ir`` option to be used with Standard Json, Assembler and Linker modes.
1112

1213

1314
Bugfixes:

solc/CommandLineParser.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,16 @@ General Information)").c_str(),
927927
else
928928
m_options.input.mode = InputMode::Compiler;
929929

930+
if (
931+
m_args.count(g_strExperimentalViaIR) > 0 &&
932+
m_options.input.mode != InputMode::Compiler &&
933+
m_options.input.mode != InputMode::CompilerWithASTImport
934+
)
935+
{
936+
serr() << "The option --" << g_strExperimentalViaIR << " is only supported in the compiler mode." << endl;
937+
return false;
938+
}
939+
930940
if (!parseInputPathsAndRemappings())
931941
return false;
932942

test/solc/CommandLineParser.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ BOOST_AUTO_TEST_CASE(assembly_mode_options)
262262
"--error-recovery", // Ignored in assembly mode
263263
"--overwrite",
264264
"--evm-version=spuriousDragon",
265-
"--experimental-via-ir", // Ignored in assembly mode
266265
"--revert-strings=strip", // Accepted but has no effect in assembly mode
267266
"--pretty-json",
268267
"--json-indent=1",
@@ -357,7 +356,6 @@ BOOST_AUTO_TEST_CASE(standard_json_mode_options)
357356
"--output-dir=/tmp/out", // Accepted but has no effect in Standard JSON mode
358357
"--overwrite", // Accepted but has no effect in Standard JSON mode
359358
"--evm-version=spuriousDragon", // Ignored in Standard JSON mode
360-
"--experimental-via-ir", // Ignored in Standard JSON mode
361359
"--revert-strings=strip", // Accepted but has no effect in Standard JSON mode
362360
"--pretty-json",
363361
"--json-indent=1",
@@ -422,6 +420,32 @@ BOOST_AUTO_TEST_CASE(standard_json_mode_options)
422420
BOOST_TEST(parsedOptions.value() == expectedOptions);
423421
}
424422

423+
BOOST_AUTO_TEST_CASE(experimental_via_ir_invalid_input_modes)
424+
{
425+
static array<string, 5> const inputModeOptions = {
426+
"--assemble",
427+
"--yul",
428+
"--strict-assembly",
429+
"--standard-json",
430+
"--link",
431+
};
432+
for (string const& inputModeOption: inputModeOptions)
433+
{
434+
stringstream sout, serr;
435+
vector<string> commandLine = {
436+
"solc",
437+
"--experimental-via-ir",
438+
"file",
439+
inputModeOption,
440+
};
441+
optional<CommandLineOptions> parsedOptions = parseCommandLine(commandLine, sout, serr);
442+
443+
BOOST_TEST(sout.str() == "");
444+
BOOST_TEST(serr.str() == "The option --experimental-via-ir is only supported in the compiler mode.\n");
445+
BOOST_REQUIRE(!parsedOptions.has_value());
446+
}
447+
}
448+
425449
BOOST_AUTO_TEST_SUITE_END()
426450

427451
} // namespace solidity::frontend::test

0 commit comments

Comments
 (0)