slither icon indicating copy to clipboard operation
slither copied to clipboard

[Bug-Candidate]: Ternary operation not handled None(<class 'NoneType'>)

Open revmischa opened this issue 4 years ago • 3 comments

Describe the issue:

slither 0xed3a954c0adfc8e3f85d92729c051ff320648e30

Warning: contracts/interfaces/exchange/IExchange.sol: Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: <SPDX-License>" to each source file. Use "SPDX-License-Identifier: UNLICENSED" for non-open-source code. Please see https://spdx.org for more information.

Warning: contracts/multiply/GuniMultiplyProxyActions.sol:253:5: Warning: Unused function parameter. Remove or comment out the variable name to silence this warning.
    address initiator,
    ^---------------^

Warning: contracts/multiply/GuniMultiplyProxyActions.sol:338:3: Warning: Function state mutability can be restricted to view
  function convertTo18(address gemJoin, uint256 amt) internal returns (uint256 wad) {
  ^ (Relevant source part starts here and spans across multiple lines).


Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/slither/__main__.py", line 743, in main_impl
    ) = process_all(filename, args, detector_classes, printer_classes)
  File "/usr/local/lib/python3.9/site-packages/slither/__main__.py", line 84, in process_all
    ) = process_single(compilation, args, detector_classes, printer_classes)
  File "/usr/local/lib/python3.9/site-packages/slither/__main__.py", line 67, in process_single
    slither = Slither(target, ast_format=ast, **vars(args))
  File "/usr/local/lib/python3.9/site-packages/slither/slither.py", line 120, in __init__
    parser.parse_contracts()
  File "/usr/local/lib/python3.9/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 435, in parse_contracts
    self._analyze_third_part(contracts_to_be_analyzed, libraries)
  File "/usr/local/lib/python3.9/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 541, in _analyze_third_part
    self._analyze_variables_modifiers_functions(contract)
  File "/usr/local/lib/python3.9/site-packages/slither/solc_parsing/slither_compilation_unit_solc.py", line 614, in _analyze_variables_modifiers_functions
    contract.analyze_content_functions()
  File "/usr/local/lib/python3.9/site-packages/slither/solc_parsing/declarations/contract.py", line 378, in analyze_content_functions
    function_parser.analyze_content()
  File "/usr/local/lib/python3.9/site-packages/slither/solc_parsing/declarations/function.py", line 310, in analyze_content
    self._filter_ternary()
  File "/usr/local/lib/python3.9/site-packages/slither/solc_parsing/declarations/function.py", line 1346, in _filter_ternary
    st = SplitTernaryExpression(node.expression)
  File "/usr/local/lib/python3.9/site-packages/slither/utils/expression_manipulations.py", line 50, in __init__
    self.copy_expression(expression, self.true_expression, self.false_expression)
  File "/usr/local/lib/python3.9/site-packages/slither/utils/expression_manipulations.py", line 92, in copy_expression
    self.copy_expression(
  File "/usr/local/lib/python3.9/site-packages/slither/utils/expression_manipulations.py", line 92, in copy_expression
    self.copy_expression(
  File "/usr/local/lib/python3.9/site-packages/slither/utils/expression_manipulations.py", line 137, in copy_expression
    raise SlitherException(
slither.exceptions.SlitherException: Ternary operation not handled None(<class 'NoneType'>)
Error:
Ternary operation not handled None(<class 'NoneType'>)
Please report an issue to https://github.com/crytic/slither/issues

Code example to reproduce the issue:

0xed3a954c0adfc8e3f85d92729c051ff320648e30

Version:

0.8.2

Relevant log output:

No response

revmischa avatar Apr 02 '22 16:04 revmischa

Hi @revmischa , thank you for reporting this.

I confirm that I can reproduce the bug with slither 0.8.3. @0xalpharush: can you look into the missing ternary operator?

montyly avatar Apr 27 '22 07:04 montyly

It looks like the unused parameter of the ternary assignment is represented as a None expression

 (, amount) = resolver.getRebalanceParams(
      address(guni),
      guni.token0() == DAI ? bal0 : 0,
      guni.token1() == DAI ? bal0 : 0,
      ((((sqrtPriceX96 * sqrtPriceX96) >> 96) * 1e18) >> 96) * otherTokenTo18Conv);

0xalpharush avatar Apr 27 '22 12:04 0xalpharush

I've encountered a similar issue when running slither as follow:

  • slither src/DssDirectDepositHub.sol
File "/home/naszam/.local/lib/python3.8/site-packages/slither/utils/expression_manipulations.py", line 144, in copy_expression
    raise SlitherException(
slither.exceptions.SlitherException: Ternary operation not handled uint256(<class 'slither.core.expressions.elementary_type_name_expression.ElementaryTypeNameExpression'>)
Error:
Ternary operation not handled uint256(<class 'slither.core.expressions.elementary_type_name_expression.ElementaryTypeNameExpression'>)
Please report an issue to https://github.com/crytic/slither/issues

repo: https://github.com/makerdao/dss-direct-deposit/pull/46 slither: 0.8.3

naszam avatar May 16 '22 14:05 naszam