diff --git a/Changelog.md b/Changelog.md index deaab332d..424359671 100644 --- a/Changelog.md +++ b/Changelog.md @@ -6,6 +6,7 @@ Breaking changes: * Commandline interface: remove the text-based ast printer (``--ast``). * General: Disallow explicit conversions from external function types to ``address`` and add a member called ``address`` to them as replacement. * Type checker: Resulting type of exponentiation is equal to the type of the base. Also allow signed types for the base. + * Command line interface: Switch to the new error reporter by default. ``--old-reporter`` falls back to the deprecated old error reporter. Language Features: diff --git a/solc/CommandLineInterface.cpp b/solc/CommandLineInterface.cpp index f73bccba4..a061fc3d9 100644 --- a/solc/CommandLineInterface.cpp +++ b/solc/CommandLineInterface.cpp @@ -149,7 +149,7 @@ static string const g_strVersion = "version"; static string const g_strIgnoreMissingFiles = "ignore-missing"; static string const g_strColor = "color"; static string const g_strNoColor = "no-color"; -static string const g_strNewReporter = "new-reporter"; +static string const g_strOldReporter = "old-reporter"; static string const g_argAbi = g_strAbi; static string const g_argPrettyJson = g_strPrettyJson; @@ -189,7 +189,7 @@ static string const g_stdinFileName = g_stdinFileNameStr; static string const g_argIgnoreMissingFiles = g_strIgnoreMissingFiles; static string const g_argColor = g_strColor; static string const g_argNoColor = g_strNoColor; -static string const g_argNewReporter = g_strNewReporter; +static string const g_argOldReporter = g_strOldReporter; /// Possible arguments to for --combined-json static set const g_combinedJsonArgs @@ -704,7 +704,7 @@ Allowed options)", ) (g_argColor.c_str(), "Force colored output.") (g_argNoColor.c_str(), "Explicitly disable colored output, disabling terminal auto-detection.") - (g_argNewReporter.c_str(), "Enables new diagnostics reporter.") + (g_argOldReporter.c_str(), "Enables old diagnostics reporter.") (g_argErrorRecovery.c_str(), "Enables additional parser error recovery.") (g_argIgnoreMissingFiles.c_str(), "Ignore missing files."); po::options_description outputComponents("Output Components"); @@ -926,10 +926,10 @@ bool CommandLineInterface::processInput() m_compiler.reset(new CompilerStack(fileReader)); unique_ptr formatter; - if (m_args.count(g_argNewReporter)) - formatter = make_unique(serr(false), m_coloredOutput); - else + if (m_args.count(g_argOldReporter)) formatter = make_unique(serr(false)); + else + formatter = make_unique(serr(false), m_coloredOutput); try { @@ -1302,10 +1302,10 @@ bool CommandLineInterface::assemble( { auto const& stack = sourceAndStack.second; unique_ptr formatter; - if (m_args.count(g_argNewReporter)) - formatter = make_unique(serr(false), m_coloredOutput); - else + if (m_args.count(g_argOldReporter)) formatter = make_unique(serr(false)); + else + formatter = make_unique(serr(false), m_coloredOutput); for (auto const& error: stack.errors()) { diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh index a9ab91bc7..068f02d4c 100755 --- a/test/cmdlineTests.sh +++ b/test/cmdlineTests.sh @@ -74,7 +74,7 @@ function compileFull() set +e "$SOLC" $FULLARGS $files >/dev/null 2>"$stderr_path" local exit_code=$? - local errors=$(grep -v -E 'Warning: This is a pre-release compiler version|Warning: Experimental features are turned on|pragma experimental ABIEncoderV2|\^-------------------------------\^' < "$stderr_path") + local errors=$(grep -v -E 'Warning: This is a pre-release compiler version|Warning: Experimental features are turned on|pragma experimental ABIEncoderV2|^ +--> |^ +\||^[0-9]+ +\|' < "$stderr_path") set -e rm "$stderr_path" @@ -143,9 +143,9 @@ function test_solc_behaviour() if [[ "$solc_args" == *"--standard-json"* ]] then - sed -i -e 's/{[^{]*Warning: This is a pre-release compiler version[^}]*},\{0,1\}//' "$stdout_path" + sed -i.bak -e 's/{[^{]*Warning: This is a pre-release compiler version[^}]*},\{0,1\}//' "$stdout_path" sed -i.bak -E -e 's/ Consider adding \\"pragma solidity \^[0-9.]*;\\"//g' "$stdout_path" - sed -i -e 's/"errors":\[\],\{0,1\}//' "$stdout_path" + sed -i.bak -e 's/"errors":\[\],\{0,1\}//' "$stdout_path" # Remove explicit bytecode and references to bytecode offsets sed -i.bak -E -e 's/\"object\":\"[a-f0-9]+\"/\"object\":\"bytecode removed\"/g' "$stdout_path" sed -i.bak -E -e 's/\"opcodes\":\"[^"]+\"/\"opcodes\":\"opcodes removed\"/g' "$stdout_path" @@ -154,13 +154,18 @@ function test_solc_behaviour() sed -i.bak -E -e 's/\\n/\'$'\n/g' "$stdout_path" rm "$stdout_path.bak" else - sed -i -e '/^Warning: This is a pre-release compiler version, please do not use it in production./d' "$stderr_path" - sed -i -e 's/ Consider adding "pragma .*$//' "$stderr_path" + sed -i.bak -e '/^Warning: This is a pre-release compiler version, please do not use it in production./d' "$stderr_path" + sed -i.bak -e 's/ Consider adding "pragma .*$//' "$stderr_path" + # Remove trailing empty lines. Needs a line break to make OSX sed happy. + sed -i.bak -e '1{/^$/d +}' "$stderr_path" + rm "$stderr_path.bak" fi # Remove path to cpp file - sed -i -e 's/^\(Exception while assembling:\).*/\1/' "$stderr_path" + sed -i.bak -e 's/^\(Exception while assembling:\).*/\1/' "$stderr_path" # Remove exception class name. - sed -i -e 's/^\(Dynamic exception type:\).*/\1/' "$stderr_path" + sed -i.bak -e 's/^\(Dynamic exception type:\).*/\1/' "$stderr_path" + rm "$stderr_path.bak" if [[ $exitCode -ne "$exit_code_expected" ]] then diff --git a/test/cmdlineTests/recovery_ast_constructor/err b/test/cmdlineTests/recovery_ast_constructor/err index 1cdca6323..81c911386 100644 --- a/test/cmdlineTests/recovery_ast_constructor/err +++ b/test/cmdlineTests/recovery_ast_constructor/err @@ -1,8 +1,14 @@ -recovery_ast_constructor/input.sol:5:27: Error: Expected primary expression. - balances[tx.origin] = ; // missing RHS. - ^ -recovery_ast_constructor/input.sol:5:27: Warning: Recovered in Statement at ';'. - balances[tx.origin] = ; // missing RHS. - ^ +Error: Expected primary expression. + --> recovery_ast_constructor/input.sol:5:27: + | +5 | balances[tx.origin] = ; // missing RHS. + | ^ + +Warning: Recovered in Statement at ';'. + --> recovery_ast_constructor/input.sol:5:27: + | +5 | balances[tx.origin] = ; // missing RHS. + | ^ + Compilation halted after AST generation due to errors. diff --git a/test/cmdlineTests/strict_asm_jump/err b/test/cmdlineTests/strict_asm_jump/err index 95dd70c75..8463daa82 100644 --- a/test/cmdlineTests/strict_asm_jump/err +++ b/test/cmdlineTests/strict_asm_jump/err @@ -1,4 +1,6 @@ Warning: Yul and its optimizer are still experimental. Please use the output with care. -strict_asm_jump/input.sol:1:3: Error: Function not found. -{ jump(1) } - ^--^ +Error: Function not found. + --> strict_asm_jump/input.sol:1:3: + | +1 | { jump(1) } + | ^^^^ diff --git a/test/cmdlineTests/too_long_line/err b/test/cmdlineTests/too_long_line/err index bfbc8e1ed..6683949ae 100644 --- a/test/cmdlineTests/too_long_line/err +++ b/test/cmdlineTests/too_long_line/err @@ -1,6 +1,11 @@ -too_long_line/input.sol:1:1: Warning: Source file does not specify required compiler version! -contract C { -^ (Relevant source part starts here and spans across multiple lines). -too_long_line/input.sol:2:164: Error: Identifier not found or not unique. - ... ffffffffffffffffffffffffffffffffff(announcementType Type, string Announcement, string ... - ^--------------^ +Warning: Source file does not specify required compiler version! + --> too_long_line/input.sol:1:1: + | +1 | contract C { + | ^ (Relevant source part starts here and spans across multiple lines). + +Error: Identifier not found or not unique. + --> too_long_line/input.sol:2:164: + | +2 | ... ffffffffffffffffffffffffffffffffff(announcementType Type, string Announcement, string ... + | ^^^^^^^^^^^^^^^^ diff --git a/test/cmdlineTests/too_long_line_both_sides_short/err b/test/cmdlineTests/too_long_line_both_sides_short/err index 2868fcb12..aeb7c4b7d 100644 --- a/test/cmdlineTests/too_long_line_both_sides_short/err +++ b/test/cmdlineTests/too_long_line_both_sides_short/err @@ -1,6 +1,11 @@ -too_long_line_both_sides_short/input.sol:1:1: Warning: Source file does not specify required compiler version! -contract C { -^ (Relevant source part starts here and spans across multiple lines). -too_long_line_both_sides_short/input.sol:2:15: Error: Identifier not found or not unique. - function f(announcementTypeXXXXXXXXXXXXXXXXXXX ... XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Type, - ^-------------------------------------------------------------------------^ +Warning: Source file does not specify required compiler version! + --> too_long_line_both_sides_short/input.sol:1:1: + | +1 | contract C { + | ^ (Relevant source part starts here and spans across multiple lines). + +Error: Identifier not found or not unique. + --> too_long_line_both_sides_short/input.sol:2:15: + | +2 | function f(announcementTypeXXXXXXXXXXXXXXXXXXX ... XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Type, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/test/cmdlineTests/too_long_line_edge_in/err b/test/cmdlineTests/too_long_line_edge_in/err index 626451e11..edcac5dee 100644 --- a/test/cmdlineTests/too_long_line_edge_in/err +++ b/test/cmdlineTests/too_long_line_edge_in/err @@ -1,6 +1,11 @@ -too_long_line_edge_in/input.sol:1:1: Warning: Source file does not specify required compiler version! -contract C { -^ (Relevant source part starts here and spans across multiple lines). -too_long_line_edge_in/input.sol:2:36: Error: Identifier not found or not unique. - function ffffffffffffffffffffff(announcementTypeTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT Ty, string A) onlyOwner external { - ^----------------------------------------------------------------------------------------------^ +Warning: Source file does not specify required compiler version! + --> too_long_line_edge_in/input.sol:1:1: + | +1 | contract C { + | ^ (Relevant source part starts here and spans across multiple lines). + +Error: Identifier not found or not unique. + --> too_long_line_edge_in/input.sol:2:36: + | +2 | function ffffffffffffffffffffff(announcementTypeTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT Ty, string A) onlyOwner external { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/test/cmdlineTests/too_long_line_edge_out/err b/test/cmdlineTests/too_long_line_edge_out/err index 7a4f935ad..17856f629 100644 --- a/test/cmdlineTests/too_long_line_edge_out/err +++ b/test/cmdlineTests/too_long_line_edge_out/err @@ -1,6 +1,11 @@ -too_long_line_edge_out/input.sol:1:1: Warning: Source file does not specify required compiler version! -contract C { -^ (Relevant source part starts here and spans across multiple lines). -too_long_line_edge_out/input.sol:2:37: Error: Identifier not found or not unique. - ... function fffffffffffffffffffffff(announcementTypeTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT Typ, string A) onlyOwner external ... - ^----------------------------------------------------------------------------------------------^ +Warning: Source file does not specify required compiler version! + --> too_long_line_edge_out/input.sol:1:1: + | +1 | contract C { + | ^ (Relevant source part starts here and spans across multiple lines). + +Error: Identifier not found or not unique. + --> too_long_line_edge_out/input.sol:2:37: + | +2 | ... function fffffffffffffffffffffff(announcementTypeTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT Typ, string A) onlyOwner external ... + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/test/cmdlineTests/too_long_line_left_short/err b/test/cmdlineTests/too_long_line_left_short/err index 4aa830b6d..931c208c0 100644 --- a/test/cmdlineTests/too_long_line_left_short/err +++ b/test/cmdlineTests/too_long_line_left_short/err @@ -1,6 +1,11 @@ -too_long_line_left_short/input.sol:1:1: Warning: Source file does not specify required compiler version! -contract C { -^ (Relevant source part starts here and spans across multiple lines). -too_long_line_left_short/input.sol:2:15: Error: Identifier not found or not unique. - function f(announcementType Type, string Announcement, string ... - ^--------------^ +Warning: Source file does not specify required compiler version! + --> too_long_line_left_short/input.sol:1:1: + | +1 | contract C { + | ^ (Relevant source part starts here and spans across multiple lines). + +Error: Identifier not found or not unique. + --> too_long_line_left_short/input.sol:2:15: + | +2 | function f(announcementType Type, string Announcement, string ... + | ^^^^^^^^^^^^^^^^ diff --git a/test/cmdlineTests/too_long_line_multiline/err b/test/cmdlineTests/too_long_line_multiline/err index c00e43fd7..67ebcff07 100644 --- a/test/cmdlineTests/too_long_line_multiline/err +++ b/test/cmdlineTests/too_long_line_multiline/err @@ -1,6 +1,11 @@ -too_long_line_multiline/input.sol:2:5: Error: No visibility specified. Did you intend to add "public"? - function f() returns (byte _b, byte ... _b7, bytes22 _b22, bytes32 _b32) { - ^ (Relevant source part starts here and spans across multiple lines). -too_long_line_multiline/input.sol:1:1: Warning: Source file does not specify required compiler version! -contract C { -^ (Relevant source part starts here and spans across multiple lines). +Error: No visibility specified. Did you intend to add "public"? + --> too_long_line_multiline/input.sol:2:5: + | +2 | function f() returns (byte _b, byte ... _b7, bytes22 _b22, bytes32 _b32) { + | ^ (Relevant source part starts here and spans across multiple lines). + +Warning: Source file does not specify required compiler version! + --> too_long_line_multiline/input.sol:1:1: + | +1 | contract C { + | ^ (Relevant source part starts here and spans across multiple lines). diff --git a/test/cmdlineTests/too_long_line_right_short/err b/test/cmdlineTests/too_long_line_right_short/err index ed9925655..5f291b979 100644 --- a/test/cmdlineTests/too_long_line_right_short/err +++ b/test/cmdlineTests/too_long_line_right_short/err @@ -1,6 +1,11 @@ -too_long_line_right_short/input.sol:1:1: Warning: Source file does not specify required compiler version! -contract C { -^ (Relevant source part starts here and spans across multiple lines). -too_long_line_right_short/input.sol:2:164: Error: Identifier not found or not unique. - ... ffffffffffffffffffffffffffffffffff(announcementType Type, - ^--------------^ +Warning: Source file does not specify required compiler version! + --> too_long_line_right_short/input.sol:1:1: + | +1 | contract C { + | ^ (Relevant source part starts here and spans across multiple lines). + +Error: Identifier not found or not unique. + --> too_long_line_right_short/input.sol:2:164: + | +2 | ... ffffffffffffffffffffffffffffffffff(announcementType Type, + | ^^^^^^^^^^^^^^^^