-
Notifications
You must be signed in to change notification settings - Fork 6k
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
use _library_ integer constants as fixed-length array sizes #12248
Comments
I think fixed size array expect compile time constant , but here A.N will be evaluated at runtime . |
A workaround for now would be to move the constant to file level. This issue could have a duplicate somewhere by the way. |
i looked carefully and didn't find one.
interesting, this move hadn't occurred to me. thanks. feel free to close if you want (though of course i think the "issue" is still open). |
For uint constant a = 0x12345678;
import "./a.sol";
contract Hello {
uint[a] x;
} is OK, but import * as X from "./a.sol";
contract Hello {
uint[X.a] x;
} outputs |
This issue has been marked as stale due to inactivity for the last 90 days. |
Hi everyone! This issue has been automatically closed due to inactivity. |
Hey, guys! I faced the same problem with compiler version 0.8.23. Do you plan to add support for setting array length using a constant from the library? My simplified case: library MyLib {
uint256 internal constant ARR_LENGTH = 5;
function getArray() internal pure returns(uint256[ARR_LENGTH] memory arr) {
return arr;
}
}
contract MyContract {
function useArrayFromLib() external {
uint256[MyLib.ARR_LENGTH] memory arr = MyLib.getArray();
}
} |
Description
Integer constants can't be used as the sizes of fixed-length arrays, even when they come from libraries.
Environment
Steps to Reproduce
A.sol
:B.sol
:leads to
somewhat related original issue, about constants in the same file, now fixed: #716
#1290 is not the same issue; it's about grabbing constants from other contracts which are not libraries. but the workaround suggested there also works here.
The text was updated successfully, but these errors were encountered: