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 IR operation when initializing array with one-element array literal #1761

Merged
merged 2 commits into from
Mar 17, 2023

Conversation

Troublor
Copy link
Contributor

Fix #1748

I added one test to reveal the bug, but I am not sure whether tests/test_ssa_generation.py is the right place to put it. Correct me if it is not the right place.

As I mentioned in the comments of #1748, the root cause is that the AST visitor unpacks the right-hand side value of arr = [1] when visiting the AST tree. However, it is not possible to decide whether the tuple should be unpacked or not when visiting TupleExpression AST node.
So, the workaround I made in this PR is to recover the array literal when we later find (at L223 of file expression_to_slithir.py) that an array is being initialized.

@CLAassistant
Copy link

CLAassistant commented Mar 16, 2023

CLA assistant check
All committers have signed the CLA.

@0xalpharush
Copy link
Contributor

The failure for slither-read-storage is unrelated and fixed in #1743

@Troublor
Copy link
Contributor Author

I found the error messages of Lint Code Base / Pylint are related to ERRORS FOUND in MARKDOWN:[1] and Failed to call GitHub Status API!.
They are not related to my commit I think.

@montyly montyly changed the base branch from master to dev March 17, 2023 15:46
@montyly montyly merged commit baf9005 into crytic:dev Mar 17, 2023
@montyly
Copy link
Member

montyly commented Mar 17, 2023

Nice catch. Thanks @Troublor

@Troublor Troublor deleted the issue_1748 branch March 17, 2023 17:18
duckki pushed a commit to CertiKProject/slither-certik that referenced this pull request Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Assigning to array literal (len==1) to state variable results in invalid IR operation
4 participants