-
Notifications
You must be signed in to change notification settings - Fork 215
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
No version of Solidity supports octal numbers #1604
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1604 +/- ##
=======================================
Coverage 87.99% 88.00%
=======================================
Files 133 133
Lines 64953 64970 +17
=======================================
+ Hits 57156 57176 +20
+ Misses 7797 7794 -3 ☔ View full report in Codecov by Sentry. |
int public test5 = -00; | ||
int public test6 = -0; | ||
int public test7 = -01e1; | ||
int public test8 = -09.1 * 10; |
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.
Why are these numbers called octal?
If I am understanding this correctly, octals can only have digits between 0 and 7.
https://en.wikipedia.org/wiki/Octal
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.
They're using the octal notation
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.
They're using the octal notation
There cannot be a 9
digit in octal.
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.
The solidity documentation says:
Octal literals do not exist in Solidity and leading zeros are invalid.
A number with leading zeros is not necessarily an octal. All the numbers you wrote here are decimals, not octals. This is the definition of an octal: https://en.wikipedia.org/wiki/Octal
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.
I think the message should be say that leading zeros are not permitted. Even though C considers numbers with leading zeros as octals, this is not a patterns across programming languages. See Python:
>>> a = 012
File "<stdin>", line 1
a = 012
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
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.
A number with leading zeros is not an octal.
A number of with a leading zero is an octal in many if not most programming languages.
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.
This is allowed in Rust and is not an octal.
fn main() {
let a = 0120;
println!("{a}");
}
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.
I've updated the message. @LucasSte is probably not the only one who does not know octal notation.
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.
A number with leading zeros is not an octal.
A number of with a leading zero is an octal in many if not most programming languages.
It is NOT in Rust, Python, Zig, OCaml, Ruby.
It is in C/C++, JavaScript/Typecript, Java, Golang, PHP.
We have a tie!
Signed-off-by: Sean Young <sean@mess.org>
No description provided.