mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge remote-tracking branch 'origin/develop' into develop_060
This commit is contained in:
@@ -38,10 +38,12 @@ namespace solidity
|
||||
|
||||
NameAndTypeResolver::NameAndTypeResolver(
|
||||
GlobalContext& _globalContext,
|
||||
langutil::EVMVersion _evmVersion,
|
||||
map<ASTNode const*, shared_ptr<DeclarationContainer>>& _scopes,
|
||||
ErrorReporter& _errorReporter
|
||||
) :
|
||||
):
|
||||
m_scopes(_scopes),
|
||||
m_evmVersion(_evmVersion),
|
||||
m_errorReporter(_errorReporter),
|
||||
m_globalContext(_globalContext)
|
||||
{
|
||||
@@ -324,7 +326,7 @@ bool NameAndTypeResolver::resolveNamesAndTypesInternal(ASTNode& _node, bool _res
|
||||
{
|
||||
if (m_scopes.count(&_node))
|
||||
setScope(&_node);
|
||||
return ReferencesResolver(m_errorReporter, *this, _resolveInsideCode).resolve(_node);
|
||||
return ReferencesResolver(m_errorReporter, *this, m_evmVersion, _resolveInsideCode).resolve(_node);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <libsolidity/ast/ASTAnnotations.h>
|
||||
#include <libsolidity/ast/ASTVisitor.h>
|
||||
|
||||
#include <liblangutil/EVMVersion.h>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
#include <list>
|
||||
@@ -55,6 +57,7 @@ public:
|
||||
/// are filled during the lifetime of this object.
|
||||
NameAndTypeResolver(
|
||||
GlobalContext& _globalContext,
|
||||
langutil::EVMVersion _evmVersion,
|
||||
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>>& _scopes,
|
||||
langutil::ErrorReporter& _errorReporter
|
||||
);
|
||||
@@ -130,6 +133,7 @@ private:
|
||||
/// Aliases (for example `import "x" as y;`) create multiple pointers to the same scope.
|
||||
std::map<ASTNode const*, std::shared_ptr<DeclarationContainer>>& m_scopes;
|
||||
|
||||
langutil::EVMVersion m_evmVersion;
|
||||
DeclarationContainer* m_currentScope = nullptr;
|
||||
langutil::ErrorReporter& m_errorReporter;
|
||||
GlobalContext& m_globalContext;
|
||||
|
||||
@@ -350,7 +350,7 @@ bool ReferencesResolver::visit(InlineAssembly const& _inlineAssembly)
|
||||
yul::AsmAnalyzer(
|
||||
analysisInfo,
|
||||
errorsIgnored,
|
||||
yul::EVMDialect::strictAssemblyForEVM(EVMVersion{}),
|
||||
yul::EVMDialect::strictAssemblyForEVM(m_evmVersion),
|
||||
resolver
|
||||
).analyze(_inlineAssembly.operations());
|
||||
return false;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include <libsolidity/ast/ASTVisitor.h>
|
||||
#include <libsolidity/ast/ASTAnnotations.h>
|
||||
#include <liblangutil/EVMVersion.h>
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <list>
|
||||
@@ -52,10 +53,12 @@ public:
|
||||
ReferencesResolver(
|
||||
langutil::ErrorReporter& _errorReporter,
|
||||
NameAndTypeResolver& _resolver,
|
||||
langutil::EVMVersion _evmVersion,
|
||||
bool _resolveInsideCode = false
|
||||
):
|
||||
m_errorReporter(_errorReporter),
|
||||
m_resolver(_resolver),
|
||||
m_evmVersion(_evmVersion),
|
||||
m_resolveInsideCode(_resolveInsideCode)
|
||||
{}
|
||||
|
||||
@@ -99,6 +102,7 @@ private:
|
||||
|
||||
langutil::ErrorReporter& m_errorReporter;
|
||||
NameAndTypeResolver& m_resolver;
|
||||
langutil::EVMVersion m_evmVersion;
|
||||
/// Stack of return parameters.
|
||||
std::vector<ParameterList const*> m_returnParameters;
|
||||
bool const m_resolveInsideCode;
|
||||
|
||||
@@ -457,6 +457,9 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
|
||||
TypePointer varType = _variable.annotation().type;
|
||||
solAssert(!!varType, "Variable type not provided.");
|
||||
|
||||
if (auto contractType = dynamic_cast<ContractType const*>(varType))
|
||||
if (contractType->contractDefinition().isLibrary())
|
||||
m_errorReporter.typeError(_variable.location(), "The type of a variable cannot be a library.");
|
||||
if (_variable.value())
|
||||
expectType(*_variable.value(), *varType);
|
||||
if (_variable.isConstant())
|
||||
@@ -2633,12 +2636,30 @@ bool TypeChecker::visit(Identifier const& _identifier)
|
||||
if (functionType->canTakeArguments(*annotation.arguments))
|
||||
candidates.push_back(declaration);
|
||||
}
|
||||
if (candidates.empty())
|
||||
m_errorReporter.fatalTypeError(_identifier.location(), "No matching declaration found after argument-dependent lookup.");
|
||||
else if (candidates.size() == 1)
|
||||
if (candidates.size() == 1)
|
||||
annotation.referencedDeclaration = candidates.front();
|
||||
else
|
||||
m_errorReporter.fatalTypeError(_identifier.location(), "No unique declaration found after argument-dependent lookup.");
|
||||
{
|
||||
SecondarySourceLocation ssl;
|
||||
|
||||
for (Declaration const* declaration: annotation.overloadedDeclarations)
|
||||
if (declaration->location().isEmpty())
|
||||
{
|
||||
// Try to re-construct function definition
|
||||
string description;
|
||||
for (auto const& param: declaration->functionType(true)->parameterTypes())
|
||||
description += (description.empty() ? "" : ", ") + param->toString(false);
|
||||
description = "function " + _identifier.name() + "(" + description + ")";
|
||||
|
||||
ssl.append("Candidate: " + description, declaration->location());
|
||||
}
|
||||
else
|
||||
ssl.append("Candidate:", declaration->location());
|
||||
if (candidates.empty())
|
||||
m_errorReporter.fatalTypeError(_identifier.location(), ssl, "No matching declaration found after argument-dependent lookup.");
|
||||
else
|
||||
m_errorReporter.fatalTypeError(_identifier.location(), ssl, "No unique declaration found after argument-dependent lookup.");
|
||||
}
|
||||
}
|
||||
}
|
||||
solAssert(
|
||||
|
||||
Reference in New Issue
Block a user