Fix member lookup for constructor in library.

This commit is contained in:
chriseth 2020-08-03 16:35:13 +02:00
parent d31f05fcc0
commit c96e997a3c
4 changed files with 9 additions and 1 deletions

View File

@ -8,6 +8,7 @@ Compiler Features:
Bugfixes:
* SMTChecker: Fix internal error on fixed bytes index access.
* References Resolver: Fix internal bug when using constructor for library.
### 0.7.0 (2020-07-28)

View File

@ -792,6 +792,7 @@ public:
m_body(_body)
{
solAssert(_kind == Token::Constructor || _kind == Token::Function || _kind == Token::Fallback || _kind == Token::Receive, "");
solAssert(isOrdinary() == !name().empty(), "");
}
void accept(ASTVisitor& _visitor) override;

View File

@ -451,7 +451,7 @@ MemberList::MemberMap Type::boundFunctions(Type const& _type, ASTNode const& _sc
);
for (FunctionDefinition const* function: library.definedFunctions())
{
if (!function->isVisibleAsLibraryMember() || seenFunctions.count(function))
if (!function->isOrdinary() || !function->isVisibleAsLibraryMember() || seenFunctions.count(function))
continue;
seenFunctions.insert(function);
if (function->parameters().empty())
@ -3838,6 +3838,8 @@ MemberList::MemberMap TypeType::nativeMembers(ASTNode const* _currentScope) cons
{
if (dynamic_cast<ModifierDefinition const*>(declaration))
continue;
if (declaration->name().empty())
continue;
if (!contract.isLibrary() && inDerivingScope && declaration->isVisibleInDerivedContracts())
{

View File

@ -0,0 +1,4 @@
library L{ constructor() { L.x; } }
// ----
// TypeError 7634: (11-33): Constructor cannot be defined in libraries.
// TypeError 9582: (27-30): Member "x" not found or not visible after argument-dependent lookup in type(library L).