-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Ternary operator expressions and array literal indexing are not evaluated at compilation time #14129
Comments
uint8 public a = 255 + 1; gives compilation error because a cannot store more than 255, and it is evident that it will not store 255+1 as 0. On the other hand, other two lines do not show compilation error, but on calling the default getter function of a, it will give an outofbound error which means that a cannot store rvalue greater than 255. |
This is not a bug, just a limitation of the compiler. Expressions involving ternary operator or indexing of array literals are not evaluated at compilation time and the oversized constant cannot be detected. They're still subject to runtime overflow checks though. We won't be addressing this directly so I'm closing the issue, but we have #3157 in the pipeline which will generally enable the compiler to evaluate more kinds of expressions at compilation time and those two cases are likely to be covered by it as well. |
Oh, I get it. Is there any issue which I can work on? I have good experience with solidity |
Yes I want to learn solidity
…On Mon, Apr 17, 2023, 4:29 PM Jinil Shah ***@***.***> wrote:
Oh, I get it. Is there any issue which I can work on? I have good
experience with solidity
—
Reply to this email directly, view it on GitHub
<#14129 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUUA526ZRSAC3WBJ4QI32STXBUSRVANCNFSM6AAAAAAXAPB6NU>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Description
Not sure if solidity evaluates RValue at runtime or compile time.
Environment
Steps to Reproduce
The text was updated successfully, but these errors were encountered: