diff options
author | Lu Guanqun <guanqun.lu@gmail.com> | 2016-01-11 23:30:25 +0800 |
---|---|---|
committer | Lu Guanqun <guanqun.lu@gmail.com> | 2016-01-23 01:14:01 +0800 |
commit | c8b05339335d8e9166ef6863f7697bcc59f09260 (patch) | |
tree | d1808b0607d8fd8dd1f6b021c57c87be3463698e | |
parent | ac3019298a42e87a2a9182b2a80a019e31d64f88 (diff) | |
download | dexon-solidity-c8b05339335d8e9166ef6863f7697bcc59f09260.tar.gz dexon-solidity-c8b05339335d8e9166ef6863f7697bcc59f09260.tar.zst dexon-solidity-c8b05339335d8e9166ef6863f7697bcc59f09260.zip |
[cond-expr] change the end to end test
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 8 | ||||
-rw-r--r-- | test/libsolidity/SolidityEndToEndTest.cpp | 9 |
2 files changed, 11 insertions, 6 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index a8125573..016fe66a 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -758,8 +758,12 @@ bool TypeChecker::visit(Conditional const& _conditional) if (*trueType == *falseType) commonType = trueType; else - // we fake it as an equal operator, but any other comparison operator can work. - commonType = trueType->binaryOperatorResult(Token::Equal, falseType); + { + commonType = Type::commonType(trueType, falseType); + if (!commonType) + // we fake it as an equal operator, but any other comparison operator can work. + commonType = trueType->binaryOperatorResult(Token::Equal, falseType); + } if (!commonType) { typeError( diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index d7827946..0f0eb417 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -147,20 +147,21 @@ BOOST_AUTO_TEST_CASE(conditional_expression_storage_memory) contract test { bytes2[2] data1; function f(bool cond) returns (uint) { + data1[0] = "cc"; + bytes2[2] memory x; - x[0] = "aa"; bytes2[2] memory y; y[0] = "bb"; - data1 = cond ? x : y; + x = cond ? y : data1; uint ret = 0; - if (data1[0] == "aa") + if (x[0] == "bb") { ret = 1; } - if (data1[0] == "bb") + if (x[0] == "cc") { ret = 2; } |