From 2df60bec923e1bac74cde00ae9bda641ca29d6c1 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 5 Dec 2016 18:40:50 +0100 Subject: Type after shift should be type of left operand. --- test/libsolidity/SolidityEndToEndTest.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/libsolidity') diff --git a/test/libsolidity/SolidityEndToEndTest.cpp b/test/libsolidity/SolidityEndToEndTest.cpp index 837caa2d..0ac88a81 100644 --- a/test/libsolidity/SolidityEndToEndTest.cpp +++ b/test/libsolidity/SolidityEndToEndTest.cpp @@ -8505,6 +8505,21 @@ BOOST_AUTO_TEST_CASE(shift_left_uint8) BOOST_CHECK(callContractFunction("f(uint8,uint8)", u256(0x66), u256(8)) == encodeArgs(u256(0))); } +BOOST_AUTO_TEST_CASE(shift_left_larger_type) +{ + char const* sourceCode = R"( + contract C { + function f() returns (int8) { + uint8 x = 255; + int8 y = 1; + return a << b; + } + } + )"; + compileAndRun(sourceCode, 0, "C"); + BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(1) << 255)); +} + BOOST_AUTO_TEST_CASE(shift_left_assignment) { char const* sourceCode = R"( -- cgit