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

fix: lookup of type alias as member of contract #2404

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading