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 incorrect temporary variable type in NewArray operation #1777

Closed
wants to merge 2 commits into from

Conversation

Troublor
Copy link
Contributor

@Troublor Troublor commented Mar 17, 2023

Fix #1776

When setting the type of the temporary variable from NewArray expression, the original code directly use the array base type instead of the array type.
This PR re-construct the ArrayType using the base type and the depth at L792-797 of file slither/slithir/convert.py.

One imperfect point is that length of nested array is lost since it is not stored in the NewArray expression, in other words, new uint[10][](2); expression will become new uint[][](2).
Fixing this will result in a great modification in the NewArray class, which may induce breaking change. So, I just leave it for future work.

@0xalpharush
Copy link
Contributor

0xalpharush commented Mar 17, 2023

Thanks for identifying this issue! While it's reasonable to make incremental changes, it may be possible to fix this in one go. I haven't tested it a ton but I think something like this branch would simplify the code and make the IR more accurate. If you'd like to work off of it and add additional tests like for the case you mention (new uint[10][](2);), I'll assign the issue to you. I think the array string functions don't handle nested arrays properly when displaying it fwiw.

@Troublor
Copy link
Contributor Author

@0xalpharush Sure. I would like to work on that enhancement. Please assign the issue to me.

@Troublor
Copy link
Contributor Author

Closed in favor of #1784

@Troublor Troublor closed this Mar 21, 2023
@Troublor Troublor deleted the issue_1776 branch March 21, 2023 00:35
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]: Incorrect variable type for NewArray operation
2 participants