diff --git a/libsolidity/experimental/analysis/TypeInference.h b/libsolidity/experimental/analysis/TypeInference.h index 86686f556..e8e234862 100644 --- a/libsolidity/experimental/analysis/TypeInference.h +++ b/libsolidity/experimental/analysis/TypeInference.h @@ -64,6 +64,7 @@ public: bool visit(SourceUnit const&) override { return true; } bool visit(ContractDefinition const&) override { return true; } bool visit(InlineAssembly const& _inlineAssembly) override; + bool visit(ImportDirective const&) override { return true; } bool visit(PragmaDirective const&) override { return false; } bool visit(IfStatement const&) override { return true; } diff --git a/libsolidity/interface/CompilerStack.h b/libsolidity/interface/CompilerStack.h index ae0dbb631..074191dd7 100644 --- a/libsolidity/interface/CompilerStack.h +++ b/libsolidity/interface/CompilerStack.h @@ -240,6 +240,13 @@ public: /// @returns false on error. bool compile(State _stopAfter = State::CompilationSuccessful); + /// Checks whether experimental analysis is on; used in SyntaxTests to skip compilation in case it's ``true``. + /// @returns true if experimental analysis is set + bool isExperimentalAnalysis() const + { + return !!m_experimentalAnalysis; + } + /// @returns the list of sources (paths) used std::vector sourceNames() const; diff --git a/scripts/ASTImportTest.sh b/scripts/ASTImportTest.sh index c24526195..53bdaa3d5 100755 --- a/scripts/ASTImportTest.sh +++ b/scripts/ASTImportTest.sh @@ -209,7 +209,15 @@ esac # boost_filesystem_bug specifically tests a local fix for a boost::filesystem # bug. Since the test involves a malformed path, there is no point in running # tests on it. See https://github.com/boostorg/filesystem/issues/176 -IMPORT_TEST_FILES=$(find "${TEST_DIRS[@]}" -name "*.sol" -and -not -name "boost_filesystem_bug.sol" -not -path "*/experimental/*") +# In addition, exclude all experimental Solidity tests (new type inference system) +EXCLUDE_FILES=( + boost_filesystem_bug.sol + pragma_experimental_solidity.sol +) +IMPORT_TEST_FILES=$(find "${TEST_DIRS[@]}" -name "*.sol" -and $(printf "! -name %s " ${EXCLUDE_FILES[@]}) -not -path "*/experimental/*") + +echo $IMPORT_TEST_FILES +exit NSOURCES="$(echo "${IMPORT_TEST_FILES}" | wc -l)" echo "Looking at ${NSOURCES} .sol files..." diff --git a/test/libsolidity/SyntaxTest.cpp b/test/libsolidity/SyntaxTest.cpp index ad53c2b26..83756931d 100644 --- a/test/libsolidity/SyntaxTest.cpp +++ b/test/libsolidity/SyntaxTest.cpp @@ -67,7 +67,7 @@ void SyntaxTest::parseAndAnalyze() { setupCompiler(); - if (compiler().parse() && compiler().analyze()) + if (compiler().parse() && compiler().analyze() && !compiler().isExperimentalAnalysis()) try { if (!compiler().compile()) diff --git a/test/libsolidity/semanticTests/experimental/stub.sol b/test/libsolidity/semanticTests/experimental/stub.sol index 7f3061fe7..f575a1b89 100644 --- a/test/libsolidity/semanticTests/experimental/stub.sol +++ b/test/libsolidity/semanticTests/experimental/stub.sol @@ -85,6 +85,8 @@ contract C { } } // ==== +// EVMVersion: >=constantinople +// ==== // compileViaYul: true // ---- // (): 0 -> 0 diff --git a/test/libsolidity/syntaxTests/pragma/experimental_solidity.sol b/test/libsolidity/syntaxTests/experimental/import/experimental_solidity.sol similarity index 100% rename from test/libsolidity/syntaxTests/pragma/experimental_solidity.sol rename to test/libsolidity/syntaxTests/experimental/import/experimental_solidity.sol diff --git a/test/libsolidity/syntaxTests/pragma/experimental_solidity_multisource_not_all_enable.sol b/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_multisource_not_all_enable.sol similarity index 100% rename from test/libsolidity/syntaxTests/pragma/experimental_solidity_multisource_not_all_enable.sol rename to test/libsolidity/syntaxTests/experimental/import/experimental_solidity_multisource_not_all_enable.sol diff --git a/test/libsolidity/syntaxTests/pragma/experimental_solidity_out_of_order_1.sol b/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_out_of_order_1.sol similarity index 100% rename from test/libsolidity/syntaxTests/pragma/experimental_solidity_out_of_order_1.sol rename to test/libsolidity/syntaxTests/experimental/import/experimental_solidity_out_of_order_1.sol diff --git a/test/libsolidity/syntaxTests/pragma/experimental_solidity_out_of_order_2.sol b/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_out_of_order_2.sol similarity index 100% rename from test/libsolidity/syntaxTests/pragma/experimental_solidity_out_of_order_2.sol rename to test/libsolidity/syntaxTests/experimental/import/experimental_solidity_out_of_order_2.sol diff --git a/test/libsolidity/syntaxTests/pragma/experimental_solidity_wrong_evm_version.sol b/test/libsolidity/syntaxTests/experimental/import/experimental_solidity_wrong_evm_version.sol similarity index 100% rename from test/libsolidity/syntaxTests/pragma/experimental_solidity_wrong_evm_version.sol rename to test/libsolidity/syntaxTests/experimental/import/experimental_solidity_wrong_evm_version.sol diff --git a/test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_1.sol b/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_1.sol similarity index 75% rename from test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_1.sol rename to test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_1.sol index beec24c1e..034cbcfb1 100644 --- a/test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_1.sol +++ b/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_1.sol @@ -6,3 +6,5 @@ import std.stub; // ---- // Warning 2264: (std.stub:63-92): Experimental features are turned on. Do not use experimental features on live deployments. // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. +// Info 4164: (std.stub:94-117): Inferred type: () -> () +// Info 4164: (std.stub:111-113): Inferred type: () diff --git a/test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_2.sol b/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_2.sol similarity index 76% rename from test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_2.sol rename to test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_2.sol index 85d3a4ac7..e7d82a5bd 100644 --- a/test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_2.sol +++ b/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_2.sol @@ -6,3 +6,5 @@ import std.stub as stub; // ---- // Warning 2264: (std.stub:63-92): Experimental features are turned on. Do not use experimental features on live deployments. // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. +// Info 4164: (std.stub:94-117): Inferred type: () -> () +// Info 4164: (std.stub:111-113): Inferred type: () diff --git a/test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_3.sol b/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_3.sol similarity index 69% rename from test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_3.sol rename to test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_3.sol index 7e51a73b1..1a27e89e8 100644 --- a/test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_3.sol +++ b/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_3.sol @@ -6,3 +6,6 @@ import { identity } from std.stub; // ---- // Warning 2264: (std.stub:63-92): Experimental features are turned on. Do not use experimental features on live deployments. // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. +// Info 4164: (std.stub:94-117): Inferred type: () -> () +// Info 4164: (std.stub:111-113): Inferred type: () +// Info 4164: (40-48): Inferred type: () -> () diff --git a/test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_4.sol b/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_4.sol similarity index 76% rename from test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_4.sol rename to test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_4.sol index 3c4ff41d6..7ccfa1950 100644 --- a/test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_4.sol +++ b/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_4.sol @@ -6,3 +6,5 @@ import * as stub from std.stub; // ---- // Warning 2264: (std.stub:63-92): Experimental features are turned on. Do not use experimental features on live deployments. // Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. +// Info 4164: (std.stub:94-117): Inferred type: () -> () +// Info 4164: (std.stub:111-113): Inferred type: () diff --git a/test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_without_pragma_1.sol b/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_without_pragma_1.sol similarity index 100% rename from test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_without_pragma_1.sol rename to test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_without_pragma_1.sol diff --git a/test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_without_pragma_2.sol b/test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_without_pragma_2.sol similarity index 100% rename from test/libsolidity/syntaxTests/experimental/parsing_stdlib_import_without_pragma_2.sol rename to test/libsolidity/syntaxTests/experimental/import/parsing_stdlib_import_without_pragma_2.sol diff --git a/test/libsolidity/syntaxTests/experimental_keywords.sol b/test/libsolidity/syntaxTests/experimental/inference/experimental_keywords.sol similarity index 100% rename from test/libsolidity/syntaxTests/experimental_keywords.sol rename to test/libsolidity/syntaxTests/experimental/inference/experimental_keywords.sol diff --git a/test/libsolidity/syntaxTests/experimental/inference/import_and_call_stdlib_function.sol b/test/libsolidity/syntaxTests/experimental/inference/import_and_call_stdlib_function.sol new file mode 100644 index 000000000..8f2071c78 --- /dev/null +++ b/test/libsolidity/syntaxTests/experimental/inference/import_and_call_stdlib_function.sol @@ -0,0 +1,24 @@ +pragma experimental solidity; + +import { identity as id } from std.stub; + +contract C +{ + fallback() external + { + id(); + } +} + +// ==== +// EVMVersion: >=constantinople +// ---- +// Warning 2264: (std.stub:63-92): Experimental features are turned on. Do not use experimental features on live deployments. +// Warning 2264: (0-29): Experimental features are turned on. Do not use experimental features on live deployments. +// Info 4164: (std.stub:94-117): Inferred type: () -> () +// Info 4164: (std.stub:111-113): Inferred type: () +// Info 4164: (40-48): Inferred type: () -> () +// Info 4164: (90-135): Inferred type: () -> () +// Info 4164: (98-100): Inferred type: () +// Info 4164: (124-128): Inferred type: () +// Info 4164: (124-126): Inferred type: () -> () diff --git a/test/stopAfterParseTests.sh b/test/stopAfterParseTests.sh index 7d74704c5..a041adba2 100755 --- a/test/stopAfterParseTests.sh +++ b/test/stopAfterParseTests.sh @@ -70,5 +70,5 @@ while read -r file; do echo "$file" exit 1 fi -done < <(find "${REPO_ROOT}/test" -iname "*.sol" -and -not -name "documentation.sol" -and -not -name "boost_filesystem_bug.sol") +done < <(find "${REPO_ROOT}/test" -iname "*.sol" -and -not -name "documentation.sol" -and -not -name "boost_filesystem_bug.sol" -not -path "*/experimental/*") echo