Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
revmischa opened this issue Apr 2, 2022 · 3 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@revmischa
Copy link

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 revmischa added the bug-candidate Bugs reports that are not yet confirmed label Apr 2, 2022
@montyly
Copy link
Member

montyly commented Apr 27, 2022

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 montyly added bug Something isn't working and removed bug-candidate Bugs reports that are not yet confirmed labels Apr 27, 2022
@0xalpharush
Copy link
Contributor

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);

@naszam
Copy link

naszam commented May 16, 2022

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: makerdao/dss-direct-deposit#46
slither: 0.8.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants