Skip to content

Commit

Permalink
Merge pull request #1856 from crytic/dev-remove-assertion
Browse files Browse the repository at this point in the history
Remove assertion in unary operation
  • Loading branch information
montyly authored May 5, 2023
2 parents 6a77485 + e51cee6 commit df0b7ce
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion slither/visitors/slithir/expression_to_slithir.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@ def _post_unary_operation(self, expression: UnaryOperation) -> None:
set_val(expression, value)
elif expression.type in [UnaryOperationType.MINUS_PRE]:
lvalue = TemporaryVariable(self._node)
assert isinstance(value.type, ElementaryType)
operation = Binary(lvalue, Constant("0", value.type), value, BinaryType.SUBTRACTION)
operation.set_expression(expression)
self._result.append(operation)
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/solc_parsing/test_ast_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ def make_version(minor: int, patch_min: int, patch_max: int) -> List[str]:
Test("yul-top-level-0.8.0.sol", ["0.8.0"]),
Test("complex_imports/import_aliases_issue_1319/test.sol", ["0.5.12"]),
Test("yul-state-constant-access.sol", ["0.8.16"]),
Test("negate-unary-element.sol", ["0.8.16"]),
]
# create the output folder if needed
try:
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"T": {
"a(int256[])": "digraph{\n0[label=\"Node Type: ENTRY_POINT 0\n\"];\n0->1;\n1[label=\"Node Type: RETURN 1\n\"];\n}\n"
}
}
5 changes: 5 additions & 0 deletions tests/e2e/solc_parsing/test_data/negate-unary-element.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
contract T {
function a(int256[] memory data) public returns(int256) {
return -data[0];
}
}

0 comments on commit df0b7ce

Please sign in to comment.