mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Check if using for refers to a library earlier.
This commit is contained in:
parent
8d3c2ba6d9
commit
76468f19fe
@ -10,6 +10,7 @@ Compiler Features:
|
||||
|
||||
Bugfixes:
|
||||
* NatSpec: Do not consider ``////`` and ``/***`` as NatSpec comments.
|
||||
* Type Checker: Fix internal error related to ``using for`` applied to non-libraries.
|
||||
|
||||
|
||||
### 0.6.10 (2020-06-11)
|
||||
|
@ -395,6 +395,15 @@ void DeclarationTypeChecker::endVisit(VariableDeclaration const& _variable)
|
||||
|
||||
}
|
||||
|
||||
void DeclarationTypeChecker::endVisit(UsingForDirective const& _usingFor)
|
||||
{
|
||||
ContractDefinition const* library = dynamic_cast<ContractDefinition const*>(
|
||||
_usingFor.libraryName().annotation().referencedDeclaration
|
||||
);
|
||||
if (!library || !library->isLibrary())
|
||||
m_errorReporter.fatalTypeError(4357_error, _usingFor.libraryName().location(), "Library name expected.");
|
||||
}
|
||||
|
||||
bool DeclarationTypeChecker::check(ASTNode const& _node)
|
||||
{
|
||||
auto watcher = m_errorReporter.errorWatcher();
|
||||
|
@ -58,6 +58,7 @@ private:
|
||||
void endVisit(ArrayTypeName const& _typeName) override;
|
||||
void endVisit(VariableDeclaration const& _variable) override;
|
||||
bool visit(StructDefinition const& _struct) override;
|
||||
void endVisit(UsingForDirective const& _usingForDirective) override;
|
||||
|
||||
langutil::ErrorReporter& m_errorReporter;
|
||||
langutil::EVMVersion m_evmVersion;
|
||||
|
@ -313,15 +313,6 @@ void TypeChecker::endVisit(InheritanceSpecifier const& _inheritance)
|
||||
}
|
||||
}
|
||||
|
||||
void TypeChecker::endVisit(UsingForDirective const& _usingFor)
|
||||
{
|
||||
ContractDefinition const* library = dynamic_cast<ContractDefinition const*>(
|
||||
_usingFor.libraryName().annotation().referencedDeclaration
|
||||
);
|
||||
if (!library || !library->isLibrary())
|
||||
m_errorReporter.fatalTypeError(4357_error, _usingFor.libraryName().location(), "Library name expected.");
|
||||
}
|
||||
|
||||
void TypeChecker::endVisit(ModifierDefinition const& _modifier)
|
||||
{
|
||||
if (!_modifier.isImplemented() && !_modifier.virtualSemantics())
|
||||
|
@ -111,7 +111,6 @@ private:
|
||||
);
|
||||
|
||||
void endVisit(InheritanceSpecifier const& _inheritance) override;
|
||||
void endVisit(UsingForDirective const& _usingFor) override;
|
||||
void endVisit(ModifierDefinition const& _modifier) override;
|
||||
bool visit(FunctionDefinition const& _function) override;
|
||||
bool visit(VariableDeclaration const& _variable) override;
|
||||
|
10
test/libsolidity/syntaxTests/bound/bound_to_struct.sol
Normal file
10
test/libsolidity/syntaxTests/bound/bound_to_struct.sol
Normal file
@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
struct S { uint t; }
|
||||
function r() public {
|
||||
S memory x;
|
||||
x.d;
|
||||
}
|
||||
using S for S;
|
||||
}
|
||||
// ----
|
||||
// TypeError: (113-114): Library name expected.
|
Loading…
Reference in New Issue
Block a user