Merge pull request #5514 from corollari/develop

Remove unary + from the type system
This commit is contained in:
chriseth 2018-12-06 10:27:09 +01:00 committed by GitHub
commit 5fde279d2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 5 deletions

View File

@ -612,10 +612,9 @@ TypeResult IntegerType::unaryOperatorResult(Token _operator) const
// "delete" is ok for all integer types // "delete" is ok for all integer types
if (_operator == Token::Delete) if (_operator == Token::Delete)
return TypeResult{make_shared<TupleType>()}; return TypeResult{make_shared<TupleType>()};
// we allow +, -, ++ and -- // we allow -, ++ and --
else if (_operator == Token::Add || _operator == Token::Sub || else if (_operator == Token::Sub || _operator == Token::Inc ||
_operator == Token::Inc || _operator == Token::Dec || _operator == Token::Dec || _operator == Token::BitNot)
_operator == Token::BitNot)
return TypeResult{shared_from_this()}; return TypeResult{shared_from_this()};
else else
return TypeResult{""}; return TypeResult{""};

View File

@ -366,7 +366,7 @@ BOOST_AUTO_TEST_CASE(unary_operators)
{ {
char const* sourceCode = R"( char const* sourceCode = R"(
contract test { contract test {
function f(int y) { !(~+- y == 2); } function f(int y) { !(~- y == 2); }
} }
)"; )";
bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}}); bytes code = compileFirstExpression(sourceCode, {}, {{"test", "f", "y"}});

View File

@ -6,3 +6,4 @@ contract test {
} }
// ---- // ----
// SyntaxError: (70-72): Use of unary + is disallowed. // SyntaxError: (70-72): Use of unary + is disallowed.
// TypeError: (70-72): Unary operator + cannot be applied to type uint256