Repository: crytic/slither

Issue:
[Bug]: For Unary IR operations, the `type` field is a UnaryOperationType instead of UnaryType
### Describe the issue:

In Unary IR operations, the `type` field records what type of unary operation is performed. I expect this field to have type `UnaryType`, much like the type field of `Binary` has type `BinaryType`, but instead it has type `UnaryOperationType`.

`UnaryOperationType` seems inappropriate for this field, because it is an enum containing variants like `DELETE` and `PLUSPLUS_PRE`, which never actually occur in IR.



### Code example to reproduce the issue:
```
contract Test {
    function test(uint64 a) internal pure returns (uint32) {
        require(!(a > 10));
        return uint32(a); 
    }
}
```

### Version:

0.9.6

### Reproduction instructions

Set breakpoints in the `__str__` methods for `Unary` and `Binary` and examine the types of the the `type` field.



Discussion:
Yeah it should be converted to UnaryType here https://github.com/crytic/slither/blob/e5f2a86f0906fd62c6c4eccb9dbfa5ab30671a78/slither/visitors/slithir/expression_to_slithir.py#L586-L591
as is done for Binary here
https://github.com/crytic/slither/blob/e5f2a86f0906fd62c6c4eccb9dbfa5ab30671a78/slither/visitors/slithir/expression_to_slithir.py#L277
Also need to update the types to `UnaryType`
https://github.com/crytic/slither/blob/e5f2a86f0906fd62c6c4eccb9dbfa5ab30671a78/slither/slithir/operations/unary.py#L38
https://github.com/crytic/slither/blob/e5f2a86f0906fd62c6c4eccb9dbfa5ab30671a78/slither/slithir/operations/unary.py#L56

Resolving patch:
diff --git a/slither/slithir/operations/unary.py b/slither/slithir/operations/unary.py
--- a/slither/slithir/operations/unary.py
+++ b/slither/slithir/operations/unary.py
@@ -5,7 +5,6 @@
 from slither.slithir.operations.lvalue import OperationWithLValue
 from slither.slithir.utils.utils import is_valid_lvalue, is_valid_rvalue
 from slither.slithir.exceptions import SlithIRError
-from slither.core.expressions.unary_operation import UnaryOperationType
 from slither.core.variables.local_variable import LocalVariable
 from slither.slithir.variables.constant import Constant
 from slither.slithir.variables.local_variable import LocalIRVariable
@@ -35,7 +34,7 @@ def __init__(
         self,
         result: Union[TemporaryVariableSSA, TemporaryVariable],
         variable: Union[Constant, LocalIRVariable, LocalVariable],
-        operation_type: UnaryOperationType,
+        operation_type: UnaryType,
     ) -> None:
         assert is_valid_rvalue(variable)
         assert is_valid_lvalue(result)
@@ -53,7 +52,7 @@ def rvalue(self) -> Union[Constant, LocalVariable]:
         return self._variable
 
     @property
-    def type(self) -> UnaryOperationType:
+    def type(self) -> UnaryType:
         return self._type
 
     @property
diff --git a/slither/visitors/slithir/expression_to_slithir.py b/slither/visitors/slithir/expression_to_slithir.py
--- a/slither/visitors/slithir/expression_to_slithir.py
+++ b/slither/visitors/slithir/expression_to_slithir.py
@@ -50,6 +50,7 @@
     Member,
     TypeConversion,
     Unary,
+    UnaryType,
     Unpack,
     Return,
     SolidityCall,
@@ -109,6 +110,13 @@ def set_val(expression: Expression, val: Any) -> None:
     BinaryOperationType.OROR: BinaryType.OROR,
 }
 
+
+_unary_to_unary = {
+    UnaryOperationType.BANG: UnaryType.BANG,
+    UnaryOperationType.TILD: UnaryType.TILD,
+}
+
+
 _signed_to_unsigned = {
     BinaryOperationType.DIVISION_SIGNED: BinaryType.DIVISION,
     BinaryOperationType.MODULO_SIGNED: BinaryType.MODULO,
@@ -585,7 +593,7 @@ def _post_unary_operation(self, expression: UnaryOperation) -> None:
         operation: Operation
         if expression.type in [UnaryOperationType.BANG, UnaryOperationType.TILD]:
             lvalue = TemporaryVariable(self._node)
-            operation = Unary(lvalue, value, expression.type)
+            operation = Unary(lvalue, value, _unary_to_unary[expression.type])
             operation.set_expression(expression)
             self._result.append(operation)
             set_val(expression, lvalue)


Test patch: