Browse Source

Disallow comparison for reference types.

Fixes #2690
cl-refactor
chriseth 9 years ago
parent
commit
4661d4773d
  1. 4
      libsolidity/Types.h
  2. 12
      test/libsolidity/SolidityNameAndTypeResolution.cpp

4
libsolidity/Types.h

@ -409,6 +409,10 @@ public:
DataLocation location() const { return m_location; }
virtual TypePointer unaryOperatorResult(Token::Value _operator) const override;
virtual TypePointer binaryOperatorResult(Token::Value, TypePointer const&) const override
{
return TypePointer();
}
virtual unsigned memoryHeadSize() const override { return 32; }
/// @returns a copy of this type with location (recursively) changed to @a _location,

12
test/libsolidity/SolidityNameAndTypeResolution.cpp

@ -1899,6 +1899,18 @@ BOOST_AUTO_TEST_CASE(integer_boolean_operators)
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode3), TypeError);
}
BOOST_AUTO_TEST_CASE(reference_compare_operators)
{
char const* sourceCode1 = R"(
contract test { bytes a; bytes b; function() { a == b; } }
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode1), TypeError);
char const* sourceCode2 = R"(
contract test { struct s {uint a;}; s x; s y; function() { x == y; } }
)";
BOOST_CHECK_THROW(parseTextAndResolveNames(sourceCode2), TypeError);
}
BOOST_AUTO_TEST_CASE(overwrite_memory_location_external)
{
char const* sourceCode = R"(

Loading…
Cancel
Save