From df08d79623302d8eb234402c2f4f00f2b06d7646 Mon Sep 17 00:00:00 2001 From: Albert Date: Wed, 28 Nov 2018 13:23:19 +0100 Subject: Fix #5470 Remove unary + from the type system --- libsolidity/ast/Types.cpp | 7 +++---- test/libsolidity/syntaxTests/parsing/unary_plus_expression.sol | 1 + 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index c6b4211a..fd8839ca 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -612,10 +612,9 @@ TypeResult IntegerType::unaryOperatorResult(Token _operator) const // "delete" is ok for all integer types if (_operator == Token::Delete) return TypeResult{make_shared()}; - // we allow +, -, ++ and -- - else if (_operator == Token::Add || _operator == Token::Sub || - _operator == Token::Inc || _operator == Token::Dec || - _operator == Token::BitNot) + // we allow -, ++ and -- + else if (_operator == Token::Sub || _operator == Token::Inc || + _operator == Token::Dec || _operator == Token::BitNot) return TypeResult{shared_from_this()}; else return TypeResult{""}; diff --git a/test/libsolidity/syntaxTests/parsing/unary_plus_expression.sol b/test/libsolidity/syntaxTests/parsing/unary_plus_expression.sol index 5646c43b..f2542d90 100644 --- a/test/libsolidity/syntaxTests/parsing/unary_plus_expression.sol +++ b/test/libsolidity/syntaxTests/parsing/unary_plus_expression.sol @@ -6,3 +6,4 @@ contract test { } // ---- // SyntaxError: (70-72): Use of unary + is disallowed. +// TypeError: (70-72): Unary operator + cannot be applied to type uint256 -- cgit