File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -759,7 +759,7 @@ bool TypeChecker::visit(Conditional const& _conditional)
759
759
commonType = trueType;
760
760
else
761
761
// we fake it as an equal operator, but any other comparison operator can work.
762
- TypePointer commonType = trueType->binaryOperatorResult (Token::Equal, falseType);
762
+ commonType = trueType->binaryOperatorResult (Token::Equal, falseType);
763
763
if (!commonType)
764
764
{
765
765
typeError (
Original file line number Diff line number Diff line change @@ -174,6 +174,21 @@ BOOST_AUTO_TEST_CASE(conditional_expression_storage_memory)
174
174
BOOST_CHECK (callContractFunction (" f(bool)" , false ) == encodeArgs (u256 (2 )));
175
175
}
176
176
177
+ BOOST_AUTO_TEST_CASE (conditional_expression_different_types)
178
+ {
179
+ char const * sourceCode = R"(
180
+ contract test {
181
+ function f(bool cond) returns (uint) {
182
+ uint8 x = 0xcd;
183
+ uint16 y = 0xabab;
184
+ return cond ? x : y;
185
+ }
186
+ }
187
+ )" ;
188
+ compileAndRun (sourceCode);
189
+ BOOST_CHECK (callContractFunction (" f(bool)" , true ) == encodeArgs (u256 (0xcd )));
190
+ BOOST_CHECK (callContractFunction (" f(bool)" , false ) == encodeArgs (u256 (0xabab )));
191
+ }
177
192
BOOST_AUTO_TEST_CASE (recursive_calls)
178
193
{
179
194
char const * sourceCode = " contract test {\n "
You can’t perform that action at this time.
0 commit comments