Merge pull request #9563 from ethereum/constrInLib

Fix member lookup for constructor in library.
This commit is contained in:
chriseth 2020-08-05 19:07:28 +02:00 committed by GitHub
commit 98faf82d3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 1 deletions

View File

@ -9,6 +9,7 @@ Compiler Features:
Bugfixes:
* Optimizer: Keep side-effects of ``x`` in ``byte(a, shr(b, x))`` even if the constants ``a`` and ``b`` would make the expression zero unconditionally. This optimizer rule is very hard if not impossible to trigger in a way that it can result in invalid code, though.
* 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).