From 6c15757618924a0da4491a243740c7bf0f70f60f Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Wed, 26 Oct 2016 15:57:42 +0200 Subject: Type checker: move the burden of computing mobile type to commonType This solves #621 --- libsolidity/analysis/TypeChecker.cpp | 4 ++-- libsolidity/ast/Types.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'libsolidity') diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 46f4f7f6..f934b2c8 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -996,9 +996,9 @@ bool TypeChecker::visit(TupleExpression const& _tuple) fatalTypeError(components[i]->location(), "Invalid mobile type."); if (i == 0) - inlineArrayType = types[i]->mobileType(); + inlineArrayType = types[i]; else if (inlineArrayType) - inlineArrayType = Type::commonType(inlineArrayType, types[i]->mobileType()); + inlineArrayType = Type::commonType(inlineArrayType, types[i]); } } else diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 7fe97fa7..0e077b32 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -200,10 +200,10 @@ TypePointer Type::commonType(TypePointer const& _a, TypePointer const& _b) { if (!_a || !_b) return TypePointer(); - else if (_b->isImplicitlyConvertibleTo(*_a)) - return _a; - else if (_a->isImplicitlyConvertibleTo(*_b)) - return _b; + else if (_b->isImplicitlyConvertibleTo(*_a->mobileType())) + return _a->mobileType(); + else if (_a->isImplicitlyConvertibleTo(*_b->mobileType())) + return _b->mobileType(); else return TypePointer(); } -- cgit