Browse Source

byte is now an alias for byte1

cl-refactor
Lefteris Karapetsas 10 years ago
parent
commit
0cd3b15373
  1. 1
      libsolidity/Token.h
  2. 2
      libsolidity/Types.cpp
  3. 10
      test/SolidityNameAndTypeResolution.cpp

1
libsolidity/Token.h

@ -286,6 +286,7 @@ namespace solidity
K(Bytes31, "bytes31", 0) \ K(Bytes31, "bytes31", 0) \
K(Bytes32, "bytes32", 0) \ K(Bytes32, "bytes32", 0) \
K(Bytes, "bytes", 0) \ K(Bytes, "bytes", 0) \
K(Byte, "byte", 0) \
K(Address, "address", 0) \ K(Address, "address", 0) \
K(Bool, "bool", 0) \ K(Bool, "bool", 0) \
K(StringType, "string", 0) \ K(StringType, "string", 0) \

2
libsolidity/Types.cpp

@ -61,6 +61,8 @@ TypePointer Type::fromElementaryTypeName(Token::Value _typeToken)
return TypePointer(); return TypePointer();
} }
} }
else if (_typeToken == Token::Byte)
return make_shared<FixedBytesType>(1);
else if (_typeToken == Token::Address) else if (_typeToken == Token::Address)
return make_shared<IntegerType>(0, IntegerType::Modifier::Address); return make_shared<IntegerType>(0, IntegerType::Modifier::Address);
else if (_typeToken == Token::Bool) else if (_typeToken == Token::Bool)

10
test/SolidityNameAndTypeResolution.cpp

@ -1393,6 +1393,16 @@ BOOST_AUTO_TEST_CASE(test_fromElementaryTypeName)
BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes32) == *make_shared<FixedBytesType>(32)); BOOST_CHECK(*Type::fromElementaryTypeName(Token::Bytes32) == *make_shared<FixedBytesType>(32));
} }
BOOST_AUTO_TEST_CASE(test_byte_is_alias_of_byte1)
{
char const* text = R"(
contract c {
bytes arr;
function f() { byte a = arr[0];}
})";
ETH_TEST_REQUIRE_NO_THROW(parseTextAndResolveNames(text), "Type resolving failed");
}
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
} }

Loading…
Cancel
Save