Compiler error on attempting to use hexadecimal literals of length 39-41 as integers #15427
Labels
bug 🐛
low effort
There is not much implementation work to be done. The task is very easy or tiny.
low impact
Changes are not very noticeable or potential benefits are limited.
Description
Attempting to use a hexadecimal literal of length 39 as integer leads to the following compilation errors:
Attempting to use a hexadecimal literal of length 40 as integer leads to the following compilation error:
Attempting to use a hexadecimal literal of length 41 as integer leads to the following compilation errors:
I assume that these errors are as part of allowing the usage of address literals without an explicit cast.
For example, allowing
address x = 0x1234...
instead of requiringaddress x = address(0x1234...)
.In other words, a hexadecimal literal of length 39-41 is assumed
address
instead ofuint256
.You should by the least fix the error message for length 39 (need to prepend '000', not '00'), and for length 41 (need to prepend '0', not '00').
It is my opinion that you should also interpret a hexadecimal literal of length 39-41 as
uint256
instead ofaddress
.Obviously, that would prevent the usage of address literals without an explicit cast, so perhaps what's needed here is a context-based decision.
For example, interpret the hexadecimal literal as a
uint256
if used in a "uint" context, and as anaddress
if used in an "address" context.Environment
Steps to Reproduce
The text was updated successfully, but these errors were encountered: