@@ -50,6 +50,7 @@ static std::string const g_strEVMVersion = "evm-version";
5050static std::string const g_strEOFVersion = " experimental-eof-version" ;
5151static std::string const g_strViaIR = " via-ir" ;
5252static std::string const g_strExperimentalViaIR = " experimental-via-ir" ;
53+ static std::string const g_strExperimental = " experimental" ;
5354static std::string const g_strGas = " gas" ;
5455static std::string const g_strHelp = " help" ;
5556static std::string const g_strImportAst = " import-ast" ;
@@ -157,6 +158,18 @@ void CommandLineParser::checkMutuallyExclusive(std::vector<std::string> const& _
157158 }
158159}
159160
161+ void CommandLineParser::checkExperimental (std::vector<std::string> const & _optionNames)
162+ {
163+ if (!m_args.contains (g_strExperimental) && countEnabledOptions (_optionNames) > 0 )
164+ {
165+ solThrow (
166+ CommandLineValidationError,
167+ " The following options are only available in experimental mode: " + joinOptionNames (_optionNames) + " . " +
168+ " To toggle experimental mode, use the --experimental flag."
169+ );
170+ }
171+ }
172+
160173bool CompilerOutputs::operator ==(CompilerOutputs const & _other) const noexcept
161174{
162175 for (bool CompilerOutputs::* member: componentMap () | ranges::views::values)
@@ -936,6 +949,17 @@ General Information)").c_str(),
936949 ;
937950 desc.add (smtCheckerOptions);
938951
952+ po::options_description experimentalOptions (" Experimental options" );
953+ experimentalOptions.add_options ()
954+ (
955+ g_strExperimental.c_str (),
956+ " Toggle experimental mode. Note that toggling experimental mode by itself will not "
957+ " enable any experimental features, but will simply allow for such features to be enabled in the "
958+ " usual manner, whether by using specific flags or pragmas."
959+ )
960+ ;
961+ desc.add (experimentalOptions);
962+
939963 desc.add_options ()(g_strInputFile.c_str (), po::value<std::vector<std::string>>(), " input file" );
940964 return desc;
941965}
@@ -979,6 +1003,9 @@ void CommandLineParser::processArgs()
9791003 else if (m_args.count (g_strColor) > 0 )
9801004 m_options.formatting .coloredOutput = true ;
9811005
1006+ if (m_args.contains (g_strExperimental))
1007+ m_options.experimental = true ;
1008+
9821009 checkMutuallyExclusive ({
9831010 g_strHelp,
9841011 g_strLicense,
@@ -992,6 +1019,18 @@ void CommandLineParser::processArgs()
9921019 g_strImportEvmAssemblerJson,
9931020 });
9941021
1022+ checkExperimental ({
1023+ g_strLSP,
1024+ g_strImportAst,
1025+ g_strImportEvmAssemblerJson,
1026+ " ir-ast-json" ,
1027+ " ir-optimized-ast-json" ,
1028+ " yul-cfg-json" ,
1029+ " ethdebug" ,
1030+ " ethdebug-runtime" ,
1031+ g_strEOFVersion,
1032+ });
1033+
9951034 if (m_args.count (g_strHelp) > 0 )
9961035 m_options.input .mode = InputMode::Help;
9971036 else if (m_args.count (g_strLicense) > 0 )
@@ -1092,6 +1131,7 @@ void CommandLineParser::processArgs()
10921131 g_strPrettyJson,
10931132 " srcmap" ,
10941133 " srcmap-runtime" ,
1134+ g_strExperimental,
10951135 };
10961136
10971137 for (auto const & [optionName, optionValue]: m_args)
@@ -1159,6 +1199,12 @@ void CommandLineParser::processArgs()
11591199 if (!m_options.output .debugInfoSelection .has_value ())
11601200 solThrow (CommandLineValidationError, " Invalid value for --" + g_strDebugInfo + " option: " + optionValue);
11611201
1202+ if (!m_options.experimental && m_options.output .debugInfoSelection ->ethdebug )
1203+ solThrow (
1204+ CommandLineValidationError,
1205+ " --" + g_strDebugInfo + " ethdebug can only be used by toggling the --" + g_strExperimental + " flag."
1206+ );
1207+
11621208 if (m_options.output .debugInfoSelection ->snippet && !m_options.output .debugInfoSelection ->location )
11631209 solThrow (CommandLineValidationError, " To use 'snippet' with --" + g_strDebugInfo + " you must select also 'location'." );
11641210 }
0 commit comments