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]: type alias namespace collision causes assertion failure in tmp_call.py #1809

Closed
kevinclancy opened this issue Mar 29, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@kevinclancy
Copy link
Contributor

Describe the issue:

When I define I type alias in one contract and define a struct with the same name in the other contract, the type alias is used as the called field of the struct constructor call. This causes an assertion error.

Code example to reproduce the issue:

pragma solidity 0.8.13;

contract OtherTest {
    struct Z {
        int x;
        int y;
    }

    function myfunc() external {
        Z memory z = Z(2,3);
    }
}

contract DeleteTest {
    type Z is int;
}

Version:

0.9.3

Relevant log output:

...
  File "/Users/kevin.clancy/.pyenv/versions/3.9.13/lib/python3.9/site-packages/slither/visitors/slithir/expression_to_slithir.py", line 160, in __init__
    self._visit_expression(self.expression)
  File "/Users/kevin.clancy/.pyenv/versions/3.9.13/lib/python3.9/site-packages/slither/visitors/expression/expression.py", line 46, in _visit_expression
    self._visit_assignement_operation(expression)
  File "/Users/kevin.clancy/.pyenv/versions/3.9.13/lib/python3.9/site-packages/slither/visitors/expression/expression.py", line 102, in _visit_assignement_operation
    self._visit_expression(expression.expression_right)
  File "/Users/kevin.clancy/.pyenv/versions/3.9.13/lib/python3.9/site-packages/slither/visitors/expression/expression.py", line 96, in _visit_expression
    self._post_visit(expression)
  File "/Users/kevin.clancy/.pyenv/versions/3.9.13/lib/python3.9/site-packages/slither/visitors/expression/expression.py", line 276, in _post_visit
    self._post_call_expression(expression)
  File "/Users/kevin.clancy/.pyenv/versions/3.9.13/lib/python3.9/site-packages/slither/visitors/slithir/expression_to_slithir.py", line 366, in _post_call_expression
    message_call = TmpCall(called, len(args), val, expression.type_call)
  File "/Users/kevin.clancy/.pyenv/versions/3.9.13/lib/python3.9/site-packages/slither/slithir/tmp_operations/tmp_call.py", line 29, in __init__
    assert isinstance(
AssertionError
@kevinclancy kevinclancy added the bug-candidate Bugs reports that are not yet confirmed label Mar 29, 2023
@0xalpharush 0xalpharush added bug Something isn't working and removed bug-candidate Bugs reports that are not yet confirmed labels Mar 30, 2023
@0xalpharush 0xalpharush changed the title [Bug-Candidate]: type alias namespace collision causes assertion failure in tmp_call.py [Bug]: type alias namespace collision causes assertion failure in tmp_call.py Mar 30, 2023
@0xalpharush
Copy link
Contributor

I think the scope may incidentally include DeleteTest.Z despite not being available within OtherTest

if not _dict_contain(new_scope.user_defined_types, self.user_defined_types):
self.user_defined_types.update(new_scope.user_defined_types)
. This causes an issue when we call find_variable on OtherTest.Z bc it only has Z and matches here
if var_name in current_scope.user_defined_types:
return current_scope.user_defined_types[var_name], False

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

No branches or pull requests

2 participants