File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed
test/libsolidity/syntaxTests/structs Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,21 @@ Declaration const* NameAndTypeResolver::pathFromCurrentScope(vector<ASTString> c
191191{
192192 solAssert (!_path.empty (), " " );
193193 vector<Declaration const *> candidates = m_currentScope->resolveName (_path.front (), true );
194+
195+ if (!candidates.empty () && candidates.front ()->isStructMember ())
196+ {
197+ // A special case like
198+ // enum E {a}; struct S {E E;}
199+ // We are within a struct scope and resolved name is a struct member name.
200+ // We resolve again, starting from the enclosing scope now.
201+ solAssert (_path.size () == 1 , " " );
202+ solAssert (candidates.size () == 1 , " " );
203+ DeclarationContainer const * enclosingContainer = m_currentScope->enclosingContainer ();
204+ if (!enclosingContainer)
205+ return nullptr ;
206+ candidates = enclosingContainer->resolveName (_path.front (), true );
207+ }
208+
194209 for (size_t i = 1 ; i < _path.size () && candidates.size () == 1 ; i++)
195210 {
196211 if (!m_scopes.count (candidates.front ()))
Original file line number Diff line number Diff line change @@ -3,4 +3,4 @@ contract C {
33 function f (function (S memory ) external ) public {}
44}
55// ----
6- // TypeError 5172 : (25-26): Name has to refer to a struct, enum or contract .
6+ // DeclarationError 7920 : (25-26): Identifier not found or not unique .
Original file line number Diff line number Diff line change 1+ contract C {
2+ enum E {a, b, c}
3+ struct S {E X; uint E;}
4+ struct T {E T; uint E;}
5+ struct U {E E;}
6+ }
You can’t perform that action at this time.
0 commit comments