Skip to content

Commit

Permalink
Merge pull request #2404 from crytic/fix/contract-member-lookup
Browse files Browse the repository at this point in the history
fix: lookup of type alias as member of contract
  • Loading branch information
0xalpharush authored Apr 7, 2024
2 parents 34f1735 + 9cecef8 commit 8c9b7dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions slither/visitors/slithir/expression_to_slithir.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,8 +587,8 @@ def _post_member_access(self, expression: MemberAccess) -> None:
# contract A { type MyInt is int}
# contract B { function f() public{ A.MyInt test = A.MyInt.wrap(1);}}
# The logic is handled by _post_call_expression
if expression.member_name in expr.file_scope.type_aliases:
set_val(expression, expr.file_scope.type_aliases[expression.member_name])
if expression.member_name in expr.type_aliases_as_dict:
set_val(expression, expr.type_aliases_as_dict[expression.member_name])
return
# Lookup errors referred to as member of contract e.g. Test.myError.selector
if expression.member_name in expr.custom_errors_as_dict:
Expand Down
7 changes: 5 additions & 2 deletions tests/e2e/solc_parsing/test_data/type-aliases.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ struct Z {
int x;
int y;
}

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

function myfunc() external {
Z memory z = Z(2,3);
// https://github.com/crytic/slither/issues/1809
Z memory z1 = Z(2,3);
// https://github.com/crytic/slither/issues/2122
DeleteTest.Z z2 = DeleteTest.Z.wrap(1);

}
}

Expand Down

0 comments on commit 8c9b7dd

Please sign in to comment.