From 40336154641da903f5721c3f2a3d136971236ed3 Mon Sep 17 00:00:00 2001 From: Lu Guanqun Date: Thu, 5 Mar 2015 23:02:35 -0600 Subject: make it work for var x = f; --- ExpressionCompiler.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'ExpressionCompiler.cpp') diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp index 5e5442ba..4be461b2 100644 --- a/ExpressionCompiler.cpp +++ b/ExpressionCompiler.cpp @@ -822,11 +822,7 @@ bool ExpressionCompiler::visit(IndexAccess const& _indexAccess) void ExpressionCompiler::endVisit(Identifier const& _identifier) { Declaration const* declaration = _identifier.getReferencedDeclaration(); - if (declaration == nullptr) - { - // no-op - } - else if (MagicVariableDeclaration const* magicVar = dynamic_cast(declaration)) + if (MagicVariableDeclaration const* magicVar = dynamic_cast(declaration)) { if (magicVar->getType()->getCategory() == Type::Category::Contract) // "this" or "super" @@ -849,6 +845,13 @@ void ExpressionCompiler::endVisit(Identifier const& _identifier) { // no-op } + else if (declaration == nullptr && _identifier.getOverloadedDeclarations().size() > 1) + { + // var x = f; + declaration = *_identifier.getOverloadedDeclarations().begin(); + FunctionDefinition const* functionDef = dynamic_cast(declaration); + m_context << m_context.getVirtualFunctionEntryLabel(*functionDef).pushTag(); + } else { BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Identifier type not expected in expression context.")); -- cgit v1.2.3