-
Notifications
You must be signed in to change notification settings - Fork 6.1k
Add InlineArrayType to support literals conversion to statically and dynamically allocated arrays. #12883
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
Conversation
Interestingly, at a quick glance, the optimizer seems to be handling this rather well even for larger-than-16-elements-arrays (without having to use stack-to-memory). |
Random idea for a syntax test on this:
This should work already, but good to have a test for it. |
4d0b0c4
to
d197426
Compare
7347515
to
866a1d8
Compare
127548a
to
04c988f
Compare
Please note that I think it makes sense to re-unify this with tuple type again. For now, it helps to find places where it is used as an inline array, but in the end, they types are very similar, especially when we keep just putting things on the stack. |
libsolidity/ast/Types.cpp
Outdated
|
||
Type const* InlineArrayType::mobileType() const | ||
{ | ||
solUnimplemented("Decide it it has a mobile type"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the weird index access cases like [1,2,3][idx] = 42;
and return [1,2,3][idx];
, it may in the end turn out that it makes sense to assign the statically sized array of the common type of the mobile types of all component types as a mobile type here :-).
Then these index accesses could just convert the inline array to its mobile type...
However, I'm not sure what other implications setting a proper mobile type here would have, so this needs some care...
5b64bf7
to
1c14212
Compare
1c87ab1
to
f937706
Compare
a2b641c
to
51ef84c
Compare
5f8cfce
to
08e4d21
Compare
…dynamically allocated arrays.
…ConversionFunction
08e4d21
to
bb40435
Compare
This pull request is stale because it has been open for 14 days with no activity. |
This pull request was closed due to a lack of activity for 7 days after it was stale. |
Thank you for your contribution to the Solidity compiler! A team member will follow up shortly. If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother. If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix. |
Closing for now. |
fixes #11879
fixes #13085
This is an early version of the changes needed to support literals conversion to dynamic arrays. Definitely it is not ready to review yet.
Things we should not forget to test:
x = [x[1], x[0]]
, wherex
is a multi-dimensional storage array