codegen: if a member access has been resolved as a variable, follow that

This fixes at least the first example in #988
This commit is contained in:
Yoichi Hirai 2016-10-21 20:02:31 +02:00
parent 47b11ef2b8
commit acba7b92e5
No known key found for this signature in database
GPG Key ID: E7B75D080FCF7992

View File

@ -888,6 +888,18 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess)
{
// no-op
}
else if (auto variable = dynamic_cast<VariableDeclaration const*>(_memberAccess.annotation().referencedDeclaration))
{
// TODO duplicate code should be unified
if (!variable->isConstant())
setLValueFromDeclaration(*_memberAccess.annotation().referencedDeclaration, _memberAccess);
else
{
variable->value()->accept(*this);
utils().convertType(*variable->value()->annotation().type, *variable->annotation().type);
}
}
else
_memberAccess.expression().accept(*this);
}